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: .. raw:: html
curl -c "evoapi-cookie.txt" -X POST -F 'username=JOOMLA_LOGIN' -F 'password=JOOMLA_PASSWORD' "https://rest.evoweb.elancite.fr/login"
.. 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 .. raw:: html
curl -b "evoapi-cookie.txt" -X POST "https://rest.evoweb.elancite.fr/v1/products"
.. literalinclude:: _static/product.json :linenos: :language: json .. 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. 1. Choose a product into the list above an copy the prod_identification content. 2. Copy/paste the following content into a file april.json .. literalInclude:: _static/april.json :linenos: :language: json What are those parameters for? .. code-block:: + 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. 3. Submit the request and redirect the result into the file result.json .. raw:: html
curl -b "evoapi-cookie.txt" -X GET --header "Content-Type: application/json" --data @april.json "https://rest.evoweb.elancite.fr/v1/speeds/001EC08273B8/vmax" > result.json
4. Finally, decode result.json file to obtain a more clean result .. raw:: html
cat result.json | jq '.' > result.txt
.. literalInclude:: _static/max_result.json :linenos: :language: json .. seealso:: See full EvoAPi specifications for detailed explanation of json result structure.