Reputation: 1
I am trying to retrieve some historical data regarding incidents from Tomtom's api using requests module in python.
I tried this code:
#defining the retrieved properties of the incident
query = '{incidents{geometry{type,coordinates},properties{iconCategory,startTime,endTime,length}}}'
url = "https://api.tomtom.com/traffic/services/1/history/incidentDetails"
params = {
"key": "I entered my key",
"bbox": "-73.9345 40.71481 -73.95557 40.70115",
"date": "2023-05-25",
"time": "14:00:00",
"fields": "{incidents{geometry{type,coordinates},properties{iconCategory,startTime,endTime,length}}}"
}
# Send the POST request to the incident endpoint
response = requests.get(url, params = params)
print(response)
the output response was:
<Response [596]>
instead of:
<Response [200]>
Upvotes: 0
Views: 289
Reputation: 1
I tried this another request:
url = f"https://api.tomtom.com/traffic/trafficstats/1/speedIndex/52.379189,4.899431,52.389189,4.909431/2021/07/23/07:00.json?key={YOUR_API_KEY}"
the output response changed to <Response [403]>
, then I found out that the problem is because I was using my free api key instead of the paid one which is used for additional services like retrieving historical data.
Upvotes: 0