-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequests.py
50 lines (44 loc) · 1.45 KB
/
requests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import requests
from dotenv import load_dotenv
# similar to the traveltimesdk function in `plot_data.py`, but getting the data as a POST
# request instead of using the SDK. This might be useful for combining multiple isochrones
# into one request.
# load environment variables from .env file
load_dotenv()
api_key = os.getenv("API_KEY")
app_id = os.getenv("APP_ID")
# define URL
url = "https://api.traveltimeapp.com/v4/time-map"
# define request headers
headers = {
"Content-Type": "application/json",
"Accept": "application/geo+json",
"X-Application-Id": app_id,
"X-Api-Key": api_key,
}
# define request body
data = {
"arrival_searches": [
{
"id": "isochrone-0",
"coords": {"lat": -33.8698439, "lng": 151.2082848},
"arrival_time": "2024-04-21T23:30:00.000Z",
"travel_time": 1800,
"transportation": {
"type": "public_transport",
"walking_time": 900,
"cycling_time_to_station": 100,
"parking_time": 0,
"boarding_time": 0,
"driving_time_to_station": 1800,
"pt_change_delay": 0,
"disable_border_crossing": false,
},
"level_of_detail": {"scale_type": "simple", "level": "medium"},
"no_holes": false,
"polygons_filter": {"limit": 100},
"range": {"enabled": true, "width": 900},
}
]
}