Skip to content

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
Source: flowclient/async_client.py

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, default 0

    Version of the API to connect to

  • ssl_certificate: typing.Union[str, bool], default True

    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
Source: flowclient/async_client.py

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]], default None

    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
Source: flowclient/async_client.py

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
Source: flowclient/async_client.py

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], default None

    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
Source: flowclient/async_client.py

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, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    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
Source: flowclient/async_client.py

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
Source: flowclient/async_client.py

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], default None

    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
Source: flowclient/async_client.py

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, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    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
Source: flowclient/async_client.py

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, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    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
Source: flowclient/async_client.py

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]
Source: flowclient/async_client.py

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
Source: flowclient/async_client.py

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
Source: flowclient/async_client.py

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, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    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