Skip to content

flowclient.client

connect

connect(*, url: str, token: str, api_version: int = 0, ssl_certificate: Union[str, NoneType] = None) -> flowclient.connection.Connection
Source: flowclient/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, NoneType], default None

    Provide a path to an ssl certificate to use, or None to use default root certificates.

Returns

  • flowclient.connection.Connection

get_available_dates

get_available_dates(*, connection: flowclient.connection.Connection, event_types: Union[NoneType, List[str]] = None) -> dict
Source: flowclient/client.py

Get available dates for different event types from the database.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, aggregation_unit: str) -> dict
Source: flowclient/client.py

Get geography data from the database.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> dict
Source: flowclient/client.py

Run and retrieve a query of a specified kind with parameters.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> dict
Source: flowclient/client.py

Get a query by id, and return it as a geojson dict

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, location: str) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Get a dataframe from a json source.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Run and retrieve a query of a specified kind with parameters.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Get a query by id, and return it as a dataframe

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> str
Source: flowclient/client.py

Return, once ready, the location at which results of a query will be obtainable.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str) -> str
Source: flowclient/client.py

Check the status of a query.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str) -> Tuple[bool, requests.models.Response]
Source: flowclient/client.py

Check if a query id has results available.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

Returns

  • typing.Tuple[bool, requests.models.Response]

    True if the query result is available

run_query

run_query(*, connection: flowclient.connection.Connection, query_spec: dict) -> str
Source: flowclient/client.py

Run a query of a specified kind with parameters and get the identifier for it.

Parameters

  • connection: flowclient.connection.Connection

    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.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> requests.models.Response
Source: flowclient/client.py

Wait until a query id has finished running, and if it finished successfully return the reply from flowapi.

Parameters

  • connection: flowclient.connection.Connection

    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

  • requests.models.Response

    Response object containing the reply to flowapi