API Response Types

class civis.response.Response(json_data, snake_case=True, headers=None)

Custom Civis response object.

Notes

The main features of this class are that it maps camelCase to snake_case at the top level of the json object and attaches keys as attributes. Nested object keys are not changed.

Attributes

json_data (dict) This is json_data as it is originally returned to the user without the key names being changed. See Notes.
headers (dict) This is the header for the API call without changing the key names.
calls_remaining (int) Number of API calls remaining before rate limit is reached.
rate_limit (int) Total number of calls per API rate limit period.
class civis.response.PaginatedResponse(path, initial_params, endpoint)

A response object that supports iteration.

Parameters:

path : str

Make GET requests to this path.

initial_params : dict

Query params that should be passed along with each request. Note that if initial_params contains the keys page_num or limit, they will be ignored. The given dict is not modified.

endpoint : civis.base.Endpoint

An endpoint used to make API requests.

Notes

This response is returned automatically by endpoints which support pagination when the iterator kwarg is specified.

Examples

>>> client = civis.APIClient()
>>> queries = client.queries.list(iterator=True)
>>> for query in queries:
...    print(query['id'])
class civis.polling.PollableResult(poller, poller_args, polling_interval=15)

Bases: concurrent.futures._base.Future

A class for tracking pollable results.

This class will begin polling immediately upon creation, and poll for job completion once every polling_interval seconds until the job completes in Civis.

Parameters:

poller : func

A function which returns an object that has a state attribute.

poller_args : tuple

The arguments with which to call the poller function.

polling_interval : int or float

The number of seconds between API requests to check whether a result is ready.

cancel()

Not currently implemented.

failed()

Return True if the Civis job failed.

succeeded()

Return True if the job completed in Civis with no error.