TONalytica API Client
Project description
TONalytica-API-Client
The official API client and utilities to manage a TONalytica instance written in Python.
Installation
To install it you will need Python 3.6 or above. We recommend that you use a virtual environment.
pip install --upgrade tonalytica-client
This command will update tonalytica-client if you have already installed it.
API Authentication
All the API calls support authentication with an API key. TONalytica has two types of API keys:
-
User API Key: has the same permissions as the user who owns it. Can be found on a user profile page.
-
Query API Key: has access only to the query and its results. Can be found on the query page.
-
Whenever possible we recommend using a Query API key
Getting Started
from tonalytica_client import TonalyticaAPIClient
# Create API client instance
"""
:args:
API_KEY
TONALYTICA_HOST (optional): `https://tonalytica.redoubt.online/` by default
"""
tonalytica = TonalyticaAPIClient(API_KEY)
API REFERENCE
Common Endpoints
Below is an incomplete list of TONalytica's API endpoints as of V9. These may change in future versions of TONalytica.
Each endpoint is appended to your TONalytica base URL. For example:
https://tonalytica.redoubt.online/<slug>
Queries
/queries
-
GET: Returns a paginated array of query objects.
- Includes the most recent
query_result_idfor non-parameterized queries.
tonalytica.queries()
- Includes the most recent
-
POST: Create a new query object
/queries/<id>
-
GET: Returns an individual query object
tonalytica.get_query(query_id="")
-
POST: Edit an existing query object.
-
DELETE: Archive this query.
/queries/<id>/results
-
GET: Get a cached result for this query ID.
- Only works for non parameterized queries. If you attempt to GET results
for a parameterized query you'll receive the error:
no cached result found for this query. See POST instructions for this endpoint to get results for parameterized queries.
- Only works for non parameterized queries. If you attempt to GET results
for a parameterized query you'll receive the error:
-
POST: Initiates a new query execution or returns a cached result.
- The API prefers to return a cached result. If a cached result is not
available then a new execution job begins and the job object is returned. To
bypass a stale cache, include a
max_agekey which is an integer number of seconds. If the cached result is older thanmax_age, the cache is ignored and a new execution begins. If you setmax_ageto0this guarantees a new execution. - If passing parameters, they must be included in the JSON request body as
a
parametersobject.
- The API prefers to return a cached result. If a cached result is not
available then a new execution job begins and the job object is returned. To
bypass a stale cache, include a
Here's an example JSON object including different parameter types:
{
"parameters": {
"number_param": 100,
"date_param": "2020-01-01",
"date_range_param": {
"start": "2020-01-01",
"end": "2020-12-31"
}
},
"max_age": 1800
}
}
Jobs
/jobs/<job_id>
- GET: Returns a query task result (job)
- Possible statuses:
- 1 == PENDING (waiting to be executed)
- 2 == STARTED (executing)
- 3 == SUCCESS
- 4 == FAILURE
- 5 == CANCELLED
- When status is success, the job will include a
query_result_id
- Possible statuses:
Query Results
/query_results/<query_result_id>
- GET: Returns a query result
- Appending a filetype of
.csvor.jsonto this request will return a downloadable file. If you append yourapi_keyin the query string, this link will work for non-logged-in users.
- Appending a filetype of
Dashboards
/dashboards
-
GET: Returns a paginated array of dashboard objects.
tonalytica.dashboards()
-
POST: Create a new dashboard object
/dashboards/<dashboard_slug>
-
GET: Returns an individual dashboard object.
tonalytica.get_dashboard(id="")
-
DELETE: Archive this dashboard
/dashboards/<dashboard_id>
- POST: Edit an existing dashboard object.
Example scripts
With tonalytica-client installed you will have access to several example CLI scripts within your terminal.
gdpr-scrub Search for a string term in your TONalytica queries
and query results. The script returns a list of
URLs in your instance that contain references to
the search term you provide
find-tables Search the text of queries against a data source
to see which table names are used in queries of
that source. This script relies on regex that is
tested against ANSI SQL.
clone-dashboard-and-queries Completely duplicate a dashboard by copying all
its queries and visualizations.
export-queries Export all the queries of your TONalytica instance
as text files.
Documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tonalytica-client-0.1.0.tar.gz.
File metadata
- Download URL: tonalytica-client-0.1.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
381d287543a574444d19a6b3c893040f9801f14d48049e886af3965d1ef590d7
|
|
| MD5 |
08f031b8a8421bdf7723905ef401f14d
|
|
| BLAKE2b-256 |
a95f0d8e52b6dc47433e202805b15f62e1fec3a185892b46cf247db4412893e9
|
File details
Details for the file tonalytica_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tonalytica_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f95936b6fe7ff7a78818df844654361842870ccbe3cbe7484b7f2907c8ea6df
|
|
| MD5 |
9ed2a03f729b8fa5df18d620cb19b9f8
|
|
| BLAKE2b-256 |
f6b4630a966e8d25c0fb1cba8a5e1244daee79ed1ecbeea3e52d7932acdd23c4
|