@@ -11,7 +11,7 @@ This can be done on the portal through the API key management pages. It can be a
1111
1212
1313Usage
14- ^^^^^
14+ '''''
1515With an API key, you can fetch and manage data in your OS2IoT system just as well as if you were a user on the browser.
1616What you can access and manage is limited by the user group (-s) tied to the API key.
1717
@@ -20,15 +20,33 @@ With that in mind, let's dive into using an API key. Let's make a few assumption
2020- We have an API key with the value :code: `00000000-abcd-ef00-0000-012345678901 `
2121- This API key is tied to a user group with Read priviliges to an organization and all its applications
2222- There exists a :code: `GET ` endpoint for fetching applications. The route ends with :code: `/application `
23+ - The Base URL for the OS2IOT Backend is known, e.g. :code: `https://os2iot-backend.SERVERNAME.EXAMPLE/api/v1/chirpstack/ `
2324
2425There's a broad variety of applications, terminals etc. which can perform HTTP requests. To authenticate this request
25- with the API key, you must provide it as the header "x-api-key". Below, a screenshot is shown of how this is done in Postman.
26+ with the API key, you must provide it as the HTTP header "x-api-key".
27+
28+ Usage in Postman
29+ ^^^^^^^^^^^^^^^^
30+ Below, a screenshot is shown of how this can be done in Postman.
2631
2732|api-key-usage |
2833
2934The bottom half of the screenshot is the response. The request was limited to 2 applications using the :code: `limit ` query parameter.
3035As seen, the backend responded with 2 (collapsed) applications.
3136
37+ Usage in Python
38+ ^^^^^^^^^^^^^^^
39+ A simple example of making the API call in Python
40+
41+ .. code :: python
42+
43+ import requests
44+ url = " https://os2iot-backend.SERVERNAME.EXAMPLE/api/v1/application?limit=2&offset=0"
45+ headers = {
46+ ' x-api-key' : ' 00000000-abcd-ef00-0000-012345678901'
47+ }
48+ response = requests.request(" GET" , url, headers = headers)
49+ print (response.text)
3250
3351 Limitations
3452^^^^^^^^^^^
@@ -43,4 +61,4 @@ For instance, to fetch the organization tied to your API key, you can make a :co
4361
4462Currently, there's no expiration date on an API key. It will not expire unless an administrator revokes it on the key management page.
4563
46- .. |api-key-usage | image :: ./media/api-key-usage.jpg
64+ .. |api-key-usage | image :: ./media/api-key-usage.jpg
0 commit comments