forked from MAQ-Observations/post-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
API_example.py
33 lines (28 loc) · 1011 Bytes
/
API_example.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
import requests
API_KEY = '<ApiKey>'
HOST_KL = 'https://www.maq-observations.nl'
headers = {'Accept': 'application/json', 'Authorization': 'ApiKey {}'.format(API_KEY), 'Content-Type':'text/csv'}
END_POINT = '/wp-json/maq/v1/sites'
print("url ---->", HOST_KL + END_POINT)
# GET SITES
get = requests.get(HOST_KL + END_POINT, headers=headers)
print(get)
print(get.text)
#GET STATIONS VEENKAMPEN
END_POINT = '/wp-json/maq/v1/sites/1/stations'
get = requests.get(HOST_KL + END_POINT, headers=headers)
print(get)
print(get.text)
#GET STREAMS VEENKAMPEN
END_POINT = '/wp-json/maq/v1/sites/1/stations/1/streams'
get = requests.get(HOST_KL + END_POINT, headers=headers)
print(get)
print(get.text)
#GET DATA TA_2_1_1 VEENKAMPEN 2023-01-01 to 2023-01-02
END_POINT = '/wp-json/maq/v1/streams/48649/measures?from=2023-01-01&to=2023-01-02'
get = requests.get(HOST_KL + END_POINT, headers=headers)
print(get)
print(get.text)
#Alternatively: Use it as a dictionary
a = get.json()
print(a)