Use the API with cURL
In this article, you will learn how to request our API using cURL.
What is cURL ?curl is a tool for transferring data from or to a server using URLs.
It supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS.
cURL documentation is available here.
Example requests for the Portal
Take the following request, which retrieves the INFO bulletins created on 11 September 2023:
https://leportail.xmco.fr/api/advisory/?where={"advisory_type":{"$in":["INFO"]},"_created":{"$gte": "Mon, 11 Sep 2023 00:00:00 GMT","$lte": "Mon, 11 Sep 2023 23:59:59 GMT"}}
With cURL, the following arguments must be used :
- with the API token
curl -v -H "Content-Type: application/json" -H 'Authorization: Bearer <token>' -X GET 'https://leportail.xmco.fr/api/advisory/' --data-urlencode 'where={"advisory_type":{"$in":["INFO"]},"_created":{"$gte":"Mon, 11 Sep 2023 00:00:00 GMT","$lte":"Mon, 11 Sep 2023 23:59:59 GMT"}} -G
- with the session cookie
curl -v -H "Content-Type: application/json" -H "Cookie: XMSESSION=XXXXXXXX" -X GET 'https://leportail.xmco.fr/api/advisory/' --data-urlencode 'where={"advisory_type":{"$in":["INFO"]},"_created":{"$gte":"Mon, 11 Sep 2023 00:00:00 GMT","$lte":"Mon, 11 Sep 2023 23:59:59 GMT"}} -G