Function Details

Installation

To use flowfabricpy, first install it using pip:

pip install git+https://github.com/lynker-spatial/flowfabric-py#egg=flowfabricpy

Core Functions

Core functions for interacting with the FlowFabric API:

flowfabricpy.flowfabric_list_datasets()

List all available datasets

Returns:

A list containing all the available datasets (each in JSON format)

flowfabricpy.flowfabric_get_dataset(dataset_id)

Get information on a specific dataset

Parameters:

dataset_id (str) – The id of the dataset

Returns:

Metadata for the dataset in JSON format

flowfabricpy.flowfabric_get_latest_run(dataset_id, verbose=False)

Get the latest run from a dataset

Parameters:
  • dataset_id (str) – The id of the dataset

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

The latest run for the dataset in a DataTable

flowfabricpy.flowfabric_streamflow_query(dataset_id, feature_ids=None, start_time=None, end_time=None, issue_time=None, params=None, verbose=False)

Query streamflow for a dataset using given or auto-generated parameters

Parameters:
  • dataset_id (str) – The id of the dataset

  • feature_ids (list or None) – (Optional) The id(s) of the desired features

  • start_time (str or None) – (Optional) The start time for the streamflow query

  • end_time (str or None) – (Optional) The end time for the streamflow query

  • issue_time (str or None) – (Optional) The issue time for the streamflow query

  • params (dict or None) – (Optional) A list of parameters for the streamflow query

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

Streamflow data from a dataset matching the parameters given/generated

flowfabricpy.flowfabric_streamflow_estimate(dataset_id, feature_ids=None, start_time=None, end_time=None, issue_time=None, params=None, verbose=False)

Estimate size of streamflow data for a dataset using given or auto-generated parameters

Parameters:
  • dataset_id (str) – The id of the dataset

  • feature_ids (list or None) – (Optional) The id(s) of the desired features

  • start_time (str or None) – (Optional) The start time for the streamflow query

  • end_time (str or None) – (Optional) The end time for the streamflow query

  • issue_time (str or None) – (Optional) The issue time for the streamflow query

  • params (dict or None) – (Optional) A list of parameters for the streamflow query

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

A JSON object containing estimates on streamflow query matching the parameters given/generated

flowfabricpy.flowfabric_ratings_query(feature_ids, type='rem', format='arrow', verbose=False)

Query REM ratings (stage-discharge relationship)

Parameters:
  • feature_ids (list) – The id(s) of the desired features

  • type (str or None) – (Optional) The type of the ratings

  • format (str or None) – (Optional) The format of the ratings

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

A response (parsed based on format) containing the REM ratings for given features

flowfabricpy.flowfabric_ratings_estimate(feature_ids, type='rem', format='arrow', verbose=False)

Estimate size of REM ratings data

Parameters:
  • feature_ids (list) – The id(s) of the desired features

  • type (str or None) – (Optional) The type of the ratings

  • format (str or None) – (Optional) The format of the ratings

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

An estimate of REM ratings data size for given features

flowfabricpy.flowfabric_stage_query(dataset_id, params=None, verbose=False)

Query stage data (Arrow IPC)

Parameters:
  • dataset_id (str) – The id of the dataset

  • params (dict or None) – (Optional) A list of parameters for the streamflow query

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

Stage data for the given dataset

flowfabricpy.flowfabric_inundation_ids(params=dict, verbose=False)

Return inundation polygon grid ids

Parameters:
  • params (dict) – A list of parameters for the streamflow query

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

inundation polygon grid ids

flowfabricpy.flowfabric_healthz(token=None, verbose=False)

Return health status of the API

Parameters:
  • token (str or None) – (Optional) JWT bearer token

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

Health metadata for the API

flowfabricpy.get_bearer_token(force_refresh=False)

Get a JWT bearer token

Parameters:

force_refresh (bool or None) – (Optional) Force refresh cached token

Returns:

JWT bearer token

Catalog Utilities

flowfabricpy.auto_streamflow_params(dataset_id)

Auto-generate streamflow parameters for a given dataset

Parameters:

dataset_id (str) – The id of the dataset

Returns:

Dictionary containing the recommended streamflow parameters

HTTP Utilities

flowfabricpy.flowfabric_get(endpoint, token=None, verbose=False)

HTTP GET request using the flowfabric API

Parameters:
  • endpoint (str) – The endpoint for the GET request

  • token (str or None) – (Optional) JWT bearer token

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

A response object containing information from the specified endpoint

flowfabricpy.flowfabric_post(endpoint, body, token=None, verbose=False)

HTTP POST request using the flowfabric API

Parameters:
  • endpoint (str) – The endpoint for the POST request

  • body (dict) – The body of the POST request

  • token (str or None) – (Optional) JWT bearer token

  • verbose (bool or None) – (Optional) Provides extra information for debugging

Returns:

A response object containing information from the specified endpoint

Auth Utilities

flowfabricpy.flowfabric_get_token(force_refresh=False)

Get and cache an authentication token

Parameters:

force_refresh (bool or None) – (Optional) force refresh token

Returns:

The cached authentication token

flowfabricpy.flowfabric_refresh_token()

Force refresh the cached token

Returns:

The new token