blpapi.Service

class blpapi.Service

Defines a service which provides access to API data.

A Service object is obtained from a Session and contains the Operations (each of which contains its own schema) and the schema for Events which this Service may produce. A Service object is also used to create Request objects used with a Session to issue requests.

Provider services are created to generate API data and must be registered before use.

The Service object is a handle to the underlying data which is owned by the Session. Once a Service has been succesfully opened in a Session it remains accessible until the Session is terminated.

authorizationServiceName()

Get the authorization service name.

Returns

The name of the Service which must be used in order to authorize access to restricted operations on this Service. If no authorization is required to access operations on this service an empty string is returned.

Return type

str

Authorization services never require authorization to use.

createAdminEvent()
Returns

An ADMIN Event suitable for publishing to this Service

Return type

Event

Use an EventFormatter to add Messages to the Event and set fields.

createAuthorizationRequest(authorizationOperation=None)

Create an empty Request object for authorizationOperation.

Parameters

authorizationOperation – A valid operation on this service

Returns

An empty request for the specified authorizationOperation.

Return type

Request

Raises

Exception – If authorizationOperation does not identify a valid operation in the Service

An application must populate the Request before issuing it using Session.sendAuthorizationRequest().

createPublishEvent()
Returns

Event suitable for publishing to this Service

Return type

Event

Use an EventFormatter to add Messages to the Event and set fields.

createRequest(operation)

Create an empty Request object for the specified operation.

Parameters

operation – A valid operation on this service

Returns

An empty request for the specified operation.

Return type

Request

Raises

Exception – If operation does not identify a valid operation in the Service

An application must populate the Request before issuing it using Session.sendRequest().

createResponseEvent(correlationId)

Create a RESPONSE Event to answer the request.

Parameters

correlationId (CorrelationId) – Correlation id to associate with the created event

Returns

The created response event.

Return type

Event

Use an EventFormatter to add Messages to the Event and set fields.

description()
Returns

Human-readable description of this service.

Return type

str

destroy()
eventDefinitions()
Returns

An iterator over unsolicited events defined by this Service.

getEventDefinition(nameOrIndex)

Get the definition of a specified event.

Parameters

nameOrIndex (Name or str or int) – Name or index of the event

Returns

Object describing the element identified by the specified nameOrIndex.

Return type

SchemaElementDefinition

Raises
getOperation(nameOrIndex)
Parameters

nameOrIndex (Name or str or int) – Name or index of the operation

Returns

The specified operation.

Return type

Operation

Raises

Exception – If nameOrIndex is a string or a Name and hasOperation(nameOrIndex) != True, or if nameOrIndex is an integer and nameOrIndex >= numOperations().

hasEventDefinition(name)
Parameters

name (Name or str) – Event identifier

Returns

True if the specified name identifies a valid event in this Service, False otherwise.

Return type

bool

Raises

Exception – If name is neither a Name nor a string.

hasOperation(name)
Returns

True if the specified name is a valid Operation in this Service.

Return type

bool

name()
Returns

Name of this service.

Return type

str

numEventDefinitions()
Returns

The number of unsolicited events defined by this Service.

Return type

int

numOperations()
Returns

The number of Operations defined by this Service.

Return type

int

operations()
Returns

Iterator over Operations defined by this Service

toString(level=0, spacesPerLevel=4)

Convert this Service schema to a string.

Parameters
  • level (int) – Indentation level

  • spacesPerLevel (int) – Number of spaces per indentation level for this and all nested objects

Returns

This object formatted as a string

Return type

str

If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level).