Response

When calling one of the Sports Classes methods, you get an AbstractResponse object as result. Usually you only need the ok property to check if the request succeeded, and the errors and error_description property if there was an error. If the request succeeded, you can iterate directly over the AbstractResponse object. In effect, the iteration is delegated to a AbstractData object, which you can also access directly by calling the data property.

class apisports.response.AbstractResponse(client, response, data=None)[source]

Bases: object

Generic response object.

Parameters
  • client (apisports._client.Client) – Client object

  • response (requests.Response) – Response object

  • data (Union[None, dict]) – The data object returned by the API call

__iter__()[source]

Delegates iteration to the AbstractData class.

__len__()[source]

Delegates len() to the AbstractData class.

static create(client, response)[source]

AbstractResponse factory method.

Parameters

response (requests.Response) – Response object

Returns

AbstractResponse object

Return type

AbstractResponse

property data

Get the AbstractData object.

Returns

AbstractData object

Return type

AbstractData

property error_description

Get a string representation of the errors, or “Success” on success…

Returns

Error string

Return type

str

property errors

Get the errors.

Returns

Dict of errors

Return type

dict

property headers

Get response headers

Returns

Headers object

Return type

Headers

property ok

Whether the request has completed without errors.

Type

bool

property raw

Get raw Response object.

Returns

Response object.

Return type

requests.Response

property text

Get raw response text.

Returns

response body as string

Return type

str

class apisports.response.ErrorResponse(client, response, data=None)[source]

Bases: apisports.response.AbstractResponse

class apisports.response.Headers(headers)[source]

Bases: object

Response Headers details class.

Parameters

headers (requests.structures.CaseInsensitiveDict) – CaseInsensitiveDict object

property rate_limit

Maximum number of API calls per minute.

Return type

str

property rate_limit_remaining

Number of API calls remaining before reaching the limit per minute.

Return type

str

property raw

Get raw headers.

Returns

CaseInsensitiveDict object

Return type

CaseInsensitiveDict

property requests_limit

The number of requests allocated per day according to your subscription

Return type

str

property requests_remaining

The number of remaining requests per day according to your subscription.

Return type

str

property server

Get the current version of the API proxy used by APISports/RapidAPI.

Return type

str

class apisports.response.HttpErrorResponse(client, response, data=None)[source]

Bases: apisports.response.ErrorResponse

property error_description

Get a string representation of the errors, or “Success” on success…

Returns

Error string

Return type

str

property errors

Get the errors.

Returns

Dict of errors

Return type

dict

class apisports.response.SuccessResponse(client, response, data=None)[source]

Bases: apisports.response.AbstractResponse

property data

Get the AbstractData object.

Returns

AbstractData object

Return type

AbstractData

property ok

Whether the request has completed without errors.

Type

bool