Skip to main content
Solved

[Dashboard rest API] How to change exporting date from Results from an Existing Chart in python?

  • October 13, 2021
  • 1 reply
  • 617 views

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())
--------------------------------------------------------------

Best answer by Saish Redkar

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!

View original
Did this topic help you find an answer to your question?

1 reply

Saish Redkar
Expert
Forum|alt.badge.img+10
  • Expert
  • 1377 replies
  • Answer
  • October 13, 2021

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings