Package: tonalytica-client
TONalytica-API-ClientThe official API client and utilities to manage a TONalytica instance written in Python.INSTALLATIONEXAMPLE SCRIPTSInstallationTo install it you will need Python 3.6 or above. We recommend that you use avirtual environment.pipinstall--upgradetonalytica-clientThis command will updatetonalytica-clientif you have already installed it.API AuthenticationAll 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 keyGetting Startedfromtonalytica_clientimportTonalyticaAPIClient# Create API client instance""":args:API_KEYTONALYTICA_HOST (optional): `https://tonalytica.redoubt.online/` by default"""tonalytica=TonalyticaAPIClient(API_KEY)API REFERENCECommon EndpointsBelow 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/queriesGET: Returns a paginated array of query objects.Includes the most recentquery_result_idfor non-parameterized queries.tonalytica.queries()POST: Create a new query object/queries/<id>GET: Returns an individual query objecttonalytica.get_query(query_id="")POST: Edit an existing query object.DELETE: Archive this query./queries/<id>/resultsGET: 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.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 amax_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
aparametersobject.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 == SUCCESS4 == FAILURE5 == CANCELLEDWhen status is success, the job will include aquery_result_idQuery Results/query_results/<query_result_id>GET: Returns a query resultAppending 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.Dashboards/dashboardsGET: 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 scriptsWithtonalytica-clientinstalled 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.DocumentationTONalytica API at GitBookLicenseThis project is licensed under the MIT License - see theLICENSEfile for details.