flowclient.async_client¶
connect_async¶
connect_async(*, url: str, token: str, api_version: int = 0, ssl_certificate: Union[str, bool] = True) -> flowclient.async_connection.ASyncConnection
Connect to a FlowKit API server and return the resulting Connection object.
Parameters¶
-
url
:str
URL of the API server, e.g. "https://localhost:9090"
-
token
:str
JSON Web Token for this API server
-
api_version
:int
, default0
Version of the API to connect to
-
ssl_certificate
:typing.Union[str, bool]
, defaultTrue
Provide a path to an ssl certificate to use, True to use default root certificates, or False to disable ssl verification.
Returns¶
flowclient.async_connection.ASyncConnection
get_available_dates¶
get_available_dates(*, connection: flowclient.async_connection.ASyncConnection, event_types: Union[NoneType, List[str]] = None) -> dict
Get available dates for different event types from the database.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
event_types
:typing.Union[NoneType, typing.List[str]]
, defaultNone
The event types for which to return available dates (for example: ["calls", "sms"]). If None, return available dates for all available event types.
Returns¶
-
dict
Available dates in the format {event_type: [list of dates]}
get_geography¶
get_geography(*, connection: flowclient.async_connection.ASyncConnection, aggregation_unit: str) -> dict
Get geography data from the database.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
aggregation_unit
:str
aggregation unit, e.g. 'admin3'
Returns¶
-
dict
geography data as a GeoJSON FeatureCollection
get_geojson_result¶
get_geojson_result(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> dict
Run and retrieve a query of a specified kind with parameters.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_spec
:dict
A query specification to run, e.g.
{'kind':'daily_location', 'params':{'date':'2016-01-01'}}
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
dict
Geojson
get_geojson_result_by_query_id¶
get_geojson_result_by_query_id(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> dict
Get a query by id, and return it as a geojson dict
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
-
poll_interval
:int
, default1
Number of seconds to wait between checks for the query being ready
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
dict
geojson
get_json_dataframe¶
get_json_dataframe(*, connection: flowclient.async_connection.ASyncConnection, location: str) -> pandas.core.frame.DataFrame
Get a dataframe from a json source.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
location
:str
API enpoint to retrieve json from
Returns¶
-
pandas.core.frame.DataFrame
Dataframe containing the result
get_result¶
get_result(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Run and retrieve a query of a specified kind with parameters.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_spec
:dict
A query specification to run, e.g.
{'kind':'daily_location', 'date':'2016-01-01'}
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
pandas.core.frame.DataFrame
Pandas dataframe containing the results
get_result_by_query_id¶
get_result_by_query_id(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Get a query by id, and return it as a dataframe
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
-
poll_interval
:int
, default1
Number of seconds to wait between checks for the query being ready
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
pandas.core.frame.DataFrame
Dataframe containing the result
get_result_location_from_id_when_ready¶
get_result_location_from_id_when_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> str
Return, once ready, the location at which results of a query will be obtainable.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
-
poll_interval
:int
, default1
Number of seconds to wait between checks for the query being ready
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
str
Endpoint to retrieve results from
get_status¶
get_status(*, connection: flowclient.async_connection.ASyncConnection, query_id: str) -> str
Check the status of a query.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
Returns¶
-
str
Query status
query_is_ready¶
query_is_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str) -> Tuple[bool, httpx.Response]
Check if a query id has results available.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
Returns¶
-
typing.Tuple[bool, httpx.Response]
True if the query result is available
run_query¶
run_query(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict) -> str
Run a query of a specified kind with parameters and get the identifier for it.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_spec
:dict
Query specification to run
Returns¶
-
str
Identifier of the query
wait_for_query_to_be_ready¶
wait_for_query_to_be_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> httpx.Response
Wait until a query id has finished running, and if it finished successfully return the reply from flowapi.
Parameters¶
-
connection
:flowclient.async_connection.ASyncConnection
API connection to use
-
query_id
:str
Identifier of the query to retrieve
-
poll_interval
:int
, default1
Number of seconds to wait between checks for the query being ready
-
disable_progress
:typing.Union[bool, NoneType]
, defaultNone
Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
httpx.Response
Response object containing the reply to flowapi