Skip to main content

Package to help connect to Verity's Data Hub API

Project description

This package simplifies the calls to Data Hub's API.

No magic. You need to follow the Data Hub Swagger Documentation for correct formatting of your requests

Be aware that this is a new package, certainly missing many features. Feel free to contribute.

You first need to create an instance of the ApiConnector class with following parameters:

ATTENTION: this package can only be used from Data Hub version 7.0 (July 1, 2025) onward, as it uses the authentication to the the new technology (Keycloak). For previous versions, the opinum-api-connector package must be used (https://github.com/opinum/opinum-api-connector) instead.

VERSION 1.1 Improved sturdiness. Added thread lock on token requests, and a default timeout of 10 seconds on all requests (incliding token)

environment

a dictionary of environment variables

if None, ApiConnector uses your environment variables (os.environ)

Mandatory environment variables are:

  • DATAHUB_USERNAME: the Data Hub user.
    TAKE CARE: if this user has access to multiple tenants and if you do not specify a tenant id, ApiConnector will use the last tenant used.
  • DATAHUB_PASSWORD: the password for the user
  • DATAHUB_CLIENT_ID: the client id for accessing the API
  • DATAHUB_CLIENT_SECRET the corresponding secret

Optional environment variables are:

  • DATAHUB_API_URL: another API URL than the Europe SaaS one (https://api.opinum.com)
  • DATAHUB_AUTH_URL: another authentication URL than the Europe SaaS one (https://auth.opinum.com)
  • DATAHUB_PUSH_URL: another push URL than the Europe SaaS one (https://push.opinum.com)
  • DATAHUB_SCOPE: the scope of you session (default: "datahub-api")
    if you want to push data, the scope should be "datahub-api push-data"

account_id

one of the tenant ids available for the Data Hub user (default: None)

retries_when_connection_failure

number of extra attempts when no 200 or 204 return code (default: 0, maximum: 5)

request_timeout

timeout value in seconds on all requests (including fetch token) (default: 10)

log_level

sets log level for the module (default: INFO)

Once you have your ApiConnector instance, you may use the class methods

  • get
  • post
  • patch
  • put
  • delete
  • send_file_to_storage

All keyword arguments will be converted to path parameters in the API call with one important exception, the data keyword referring to the body of your call.

There are two other class methods for data pushing because we have another API for this

  • push_data
  • push_dataframe_data

There is a little bit of magic with the method multi_thread_request_on_path that splits a list of parameters Allowing to make parallel calls.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datahub_api_connector-1.1.tar.gz (10.7 kB view details)

Uploaded Source

File details

Details for the file datahub_api_connector-1.1.tar.gz.

File metadata

  • Download URL: datahub_api_connector-1.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for datahub_api_connector-1.1.tar.gz
Algorithm Hash digest
SHA256 c9684c73cf342449fa9ede80ad3fe1cfa23e4d0cef118c4d03407b3d68c34816
MD5 d8e8653c7731743467a92280962739ad
BLAKE2b-256 9a8625f54e49390eaad6c164033e3aabbeae1f46cc9d5a6c870d9a81ec951313

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page