-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from databox/python-example
Add Pyhton example
- Loading branch information
Showing
8 changed files
with
72 additions
and
679 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import databox | ||
from databox.rest import ApiException | ||
from pprint import pprint | ||
|
||
# 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 variable | ||
configuration = 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 request | ||
with databox.ApiClient(configuration, "Accept", "application/vnd.databox.v2+json",) as api_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) | ||
except ApiException as e: | ||
# Handle exceptions that occur during the API call, such as invalid data or authentication issues | ||
pprint("API Exception occurred: %s\n" % e) | ||
except Exception as e: | ||
# Handle any other unexpected exceptions | ||
pprint("An unexpected error occurred: %s\n" % e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.