This short tutorial shows how to retrieve data from the staging service with python and requests.
For IDL you can take a similar rout by adapting these instructions to Access to REST-Services in IDL.
Routes
First of all we have to know which routes to use. For this, it is recommended to take a look at the swagger ui (http://localhost:8005/ui/).
For this tutorial we will only use one route to retrieve all available SWPC events.
- /swpc_event/list
Requests
The route in question is a GET route which requires them to be called with a GET request. To create simple get requests we recommend the python package requests.
A GET request needs only a single parameter: The address which is given by the route.
r = requests.get("http://httpbin.org/get")
Implementation
Retrieve
For retrieving all SWPC events which are stored within the database we can use now a GET request.
# retrieving data print('downloading all data...') swpc_events = requests.get("http://localhost:8005/swpc_event/list").json() print(swpc_events)
Source Code
Here you can download the full python source code.