My first request
In this quick guide, we’ll walk through the utilities necessary to make an HTTP request to EvoApi, which is secured with HTTP basic authentication. We’ll then get the list of products and finish by requesting Max speeds statistics of a product.
Authenticate with HTTP
EvoApi supports HTTP Basic authentication. This allows you to protect the URLs on the web server so that only you and ElanCity can access them. In order to authenticate with HTTP, you may provide a username and password and store result cookie file.
We will use the curl utility in our examples (see Useful tools section for more information).
For HTTP Basic authentication, you will use your Joomla login as your username and your Joomla password as your password:
Note
Authentication informations are stored into the file “cookie file” named ‘evoapi-cookie.txt’ which needs to be associated with each subsequent request to EvoApi.
Warning
Your session will expire into 60 minutes, you’ll then need to authenticate again so as to obtain a new cookie file.
Get the list of products
The next step is to get your products list which contains the mandatory product identification code you will need for submitting requests
1 2 3 4 5 6 7 8 9 10 11 12 13 | {
"products": [
{
"prod_identification": "001EC087F7E1",
"name": "KAL105",
"city": "Hull",
"street_1": "Corner of Main and Bridge Streets",
"street_2": "Near the baker shop",
"longitude": 1.64391210,
"latitude": 47.26069800
}
]
}
|
Note
Each product has a unique prod_identification. You should use this id for future requests.
Explore API
The last step consist to retrieve max speed of a product between two dates.
Choose a product into the list above an copy the prod_identification content.
Copy/paste the following content into a file april.json
1 2 3 4 5 | {
"start": "2021-04-01",
"end": "2021-04-02",
"direction": 0
}
|
What are those parameters for?
+ start : the start date
+ end : the end date
+ direction : traffic direction (0=ingoing, 1=outgoing)
To summarize, we are requesting EvoApi to send Max speed between 2022-04-01 and 2022-04-03 for ingoing direction. The product identication will be provided as an argument of the request.
Submit the request and redirect the result into the file result.json
Finally, decode result.json file to obtain a more clean result
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 51 52 53 54 55 56 57 58 59 60 61 | {
"header": {
"dateEnd": "2021-04-02T23:59:59",
"dateStart": "2021-04-01T00:00:00",
"pointEnd": "2022-06-15T21:00:11",
"pointInterval": 3600,
"pointStart": "2021-04-01T01:00:00",
"units": "km/h"
},
"in": [
71,
64,
51,
57,
71,
68,
89,
72,
77,
79,
92,
86,
76,
76,
80,
77,
77,
90,
86,
85,
76,
81,
83,
0,
79,
78,
60,
65,
0,
85,
76,
84,
90,
86,
89,
82,
74,
80,
76,
75,
74,
81,
79,
83,
77,
76,
77
],
"out": [],
"prod_identification": "001EC08273B8"
}
|
See also
See full EvoAPi specifications for detailed explanation of json result structure.