Skip to main content

Hi All

I am new to coding API, i am trying to export data from a existing chart, i try to fallow this document to do it, my goal is to export the data for everyday for further analysis.
https://developers.amplitude.com/docs/dashboard-rest-api#results-from-an-existing-chart

my question is how do i setup date range parameter in my python code in order to export data from a different date range? 

thanks in advance,
mike
--------------------------------------------------------------
here is my python code 

import requests
import json
#import HTTPBasicAuth
#pip install pyamplitude
api_key = "xxxxxxxxxxxxxxxxxxxxxx"
secret_key = "xxxxxxxxxxxxxxxxxxxxxxx"
response = requests.get('https://amplitude.com/api/3/chart/mk17vo2/query', 
                        auth=(api_key, secret_key)     )
print(response)
print(response.json())
--------------------------------------------------------------

Hey @MikeCheng 

Afaik, the “Results from an Existing Chart” endpoint allows you to query any existing saved chart via the chart id. This means you can only access this chart on whatever time range you have selected and saved that chart originally. To get a new time range, you will have to change the time range in the chart, save it again and then query using the new chart id. 

For a more dynamic chart creation option, the event segmentation endpoint is the best option. Here you can use the start,end and/or i parameter to set the desired time interval dynamically when calling the api and get the results.

 

Let me know if I have interpreted your use case correctly. Hope this helps!


Reply