JSON-RPC 2.0 API
TPOSS provides the following RPC APIs:
- Balance API - API to manage subscribers balances.
- Carriers API - API to manage carriers and carrier groups.
- CDR API - API to manage CDRs.
- Charging Account API - API to manage charging accounts.
- Events API - API to manage TPOSS events.
- Session API - API to manage PCS sessions.
- Subscriber API - API to manage subscribers.
- Whitelist API - API to manage TPOSS whitelisted IMEIsv.
TPOSS RPC APIs are accessible through the TPOSS API Gateway component and not directly through TPOSS. All the APIs follow a uniform design. This design is meant to ease the adoption and consumption of the different APIs that TPOSS API Gateway exposes. The APIs are based on open protocols and common concepts to lower the barrier for developers.
All APIs follow the JSON-RPC 2.0Opens in a new tab protocol. The protocol itself is implemented by client libraries in various programming languages. The JSON-RPC 2.0 protocol specification defines the message flow between a client and a server. Whenever APIs require notification-like message behavior, the Request-ResponseOpens in a new tab pattern is used to support endpoint acknowledgement as defined by the JSON-RPC 2.0 protocol. The notification messages defined in JSON-RPC 2.0 aren’t used. Since JSON-RPC 2.0 defines a message identification used to match Request-Response pairs, it is possible to multiplex RPC calls between a single client and the TPOSS server.
Each RPC API call is an HTTP POST request with the following fields:
jsonrpc- a string specifying the JSON-RPC protocol version. It must be2.0.id- an identifier established by the client that must contain a number.method- a string representing the name of the RPC method implemented by TPOSS.params- a set of RPC call parameters.
The TPOSS APIs define RPC methods with their parameters and return types that the clients can call remotely. Whenever a client sends a request to the TPOSS API Gateway server, it can expect a response for that request. The underlying messaging protocol defines how a response is matched to a particular request.
Naming rules
Parameter and attribute names are written in camel case. For example:
ChargingAccountIdSort
Method names are prefixed with the API namespace they are part of. For example:
Subscriber.ReadCdr.List
Frontend identifiers
All the API requests require clients to identify themselves against the API. For this reason, clients may use identifiers that are then handled as opaque data by TPOSS. TPOSS uses these identifiers for request authorization and logging.
Clients must pass these two frontend identifiers in each request:
FeId(Frontend Identifier) - must be a static value associated with the client application. For example:CFP12.FeSId(Frontend Session Identifier) - must be a dynamic value generated at the client's startup. It allows TPOSS to detect malfunctioning client behavior and allows easier auditing of request logs.
Authentication
All the RPC API methods require an authentication key to be passed along with the other parameters. Each request must contain the AuthKey field and the FeId field in the params object. TPOSS API Gateway combines both fields into the authentication key that a TPOSS operator configures on the TPOSS side. If the client does not provide them or provides unknown values for TPOSS, TPOSS returns the -33333 Not authenticated error.
For more information about the authentication keys and their configuration, see the API overview document.
API parameters
All the TPOSS APIs have a set of defined input parameters described in the corresponding API documents. The parameters marked as required must be passed to the method; otherwise, TPOSS returns an error. The optional parameters are marked as optional and can be omitted in the API calls. TPOSS ignores input parameters that are not defined for the API method with no impact on the result of the API method execution. All the values that are not valid for an API method result in the error response. Additionally, the log message with the parameter and the parameter's value is printed at least at the logging level - debug.
The most API methods support a set of common parameters to enable clients to narrow down request result sets as needed. These common parameters are:
LimitOffsetSortFilterFields
You can refer to the individual API specifications to find out which API methods support these parameters.
Limit
The Limit parameter allows the client to specify an upper limit on the number of records returned in a response.
Offset
The Offset parameter allows the client to specify a number of objects to skip before collecting the result entries. The offset is taken into account after sorting if the Sort parameter is passed.
Sort
The Sort parameter allows the client to sort the results according to an attribute in the directions asc (ascending) or desc (descending). For example:
This parameter allows you to sort the API request results according to IMSI from lower to higher values.
Filter
The Filter parameter allows the client to apply specific filtering rules to the result. The following filter operations are supported:
is- equal tolte- lower than or equal tolt- lower thangte- greater than or equal togt- greater thanends_with- ends with a given patternstarts_with- starts with a given patterncontains- contains a given pattern
The ends_with, starts_with, and contains filter operators allow you to specify a pattern to match. For example:
or
All these filter operators work only with the string data but not with dates, timestamps, and IP addresses.
It's possible to specify more than one filter. Comma-separated filters are evaluated like logical and. For example:
You may use this filter to get a session by a given NAT IP address and one known NAT port.
Fields
The Fields parameter allows the client to specify a list of object attributes (separated by colons) which should be returned by a query. By removing attributes from irrelevant results, you can execute more efficient queries.
For example:
or:
or:
Common error scenarios
Despite each TPOSS API method may have its own set of possible errors, all the APIs methods share common error scenarios:
Authentication key not valid- If the authentication key can’t be verified for the calling client, the server does not allow a client to access the requested API method. In this case, the-33333error code is returned.Required field missed- If a request should contain mandatory input parameters and at least one of them is missing, the server doesn't allow a client to access the requested API method. In this case, the-30000error code is returned.Type mismatch error- If a request has input parameters and at least one of their values has the wrong data type, the-31810error code is returned with the related error message.
All the possible errors related to the API methods are described in the respective TPOSS API documents.