Push API resources Open API documentation
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 0.4.1
- Package version: 2.2.2
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Python 3.7+
If the python package is hosted on a repository, you can install directly using:
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)
Then import the package:
importdataboxInstall via Setuptools.
python setup.py install --user(or sudo python setup.py install to install the package for all users)
Then import the package:
importdataboxExecute pytest to run the tests.
Please follow the installation procedure and then run the following:
# Configuration setup for the Databox API client# The API token is used as the username for authentication# It's recommended to store your API token securely, e.g., in an environment variableconfiguration=databox.Configuration(
host="https://push.databox.com",
username="<YOUR-CUSTOM-DATA-TOKEN>",
password=""
) # It's crucial to specify the correct Accept header for the API requestwithdatabox.ApiClient(configuration, "Accept", "application/vnd.databox.v2+json",) asapi_client: api_instance=databox.DefaultApi(api_client) # Define the data to be pushed to the Databox Push API# Prepare the data you want to push to Databox# The 'key' should match a metric in your Databox account, 'value' is the data point, 'unit' is optional, and 'date' is the timestamp of the data point push_data= [{"key": "sales2", "value": 100, "unit": "USD", "date": "2021-01-01T00:00:00Z" }]
try:
api_instance.data_post(push_data=push_data) exceptApiExceptionase:
# Handle exceptions that occur during the API call, such as invalid data or authentication issuespprint("API Exception occurred: %s\n"%e)
exceptExceptionase:
# Handle any other unexpected exceptionspprint("An unexpected error occurred: %s\n"%e)