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
-
__iter__
()[source]¶ Delegates iteration to the
AbstractData
class.
-
__len__
()[source]¶ Delegates
len()
to theAbstractData
class.
-
static
create
(client, response)[source]¶ AbstractResponse factory method.
- Parameters
response (requests.Response) –
Response
object- Returns
AbstractResponse
object- Return type
-
property
data
¶ Get the
AbstractData
object.- Returns
AbstractData
object- Return type
-
property
error_description
¶ Get a string representation of the errors, or “Success” on success…
- Returns
Error string
- Return type
-
property
raw
¶ Get raw Response object.
- Returns
Response
object.- Return type
requests.Response
-
class
apisports.response.
Headers
(headers)[source]¶ Bases:
object
Response Headers details class.
- Parameters
headers (requests.structures.CaseInsensitiveDict) –
CaseInsensitiveDict
object
-
property
rate_limit_remaining
¶ Number of API calls remaining before reaching the limit per minute.
- Return type
-
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
-
property
requests_remaining
¶ The number of remaining requests per day according to your subscription.
- Return type
-
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
-
property
-
class
apisports.response.
SuccessResponse
(client, response, data=None)[source]¶ Bases:
apisports.response.AbstractResponse
-
property
data
¶ Get the
AbstractData
object.- Returns
AbstractData
object- Return type
-
property