... | ... | @@ -74,8 +74,47 @@ The API can return a few different status codes depending on if the call was suc |
|
|
| 401 Unauthorized | Current Bearer token is no longer valid. |
|
|
|
| 403 Forbidden | You are not allowed to perform this action. Most likely due to not having enough rights to perform this action. |
|
|
|
| 404 Not Found | The URL to the API is not correct, or cannot be found. |
|
|
|
| 429 Too Many Requests | The maximum amount of allowable calls has been reached for this API request. The current API rate limiter uses a window of an hour to check if the amount of requests exceeds a pre-defined number |
|
|
|
| 429 Too Many Requests | The maximum amount of allowable calls has been reached for this API request. The current API rate limiter uses a window of an hour to check if the amount of requests exceeds a pre-defined number. Currently, this number is set to a maximum of 10 requests per action. |
|
|
|
| 500 Unexpected Error | An unexpected error has occurred. |
|
|
|
|
|
|
### Examples
|
|
|
... |
|
|
\ No newline at end of file |
|
|
The most common library in Python to make API requests is the library [`requests`](https://docs.python-requests.org/en/latest/). The requests library isn’t part of the standard Python library, so you’ll need to install it to get started.
|
|
|
|
|
|
If you use pip to manage your Python packages, you can install requests using the following command:
|
|
|
```
|
|
|
pip install requests
|
|
|
```
|
|
|
|
|
|
```python
|
|
|
import requests
|
|
|
|
|
|
URL = "https://portal.robotsindeklas.nl/API/v1"
|
|
|
|
|
|
data_auth = {
|
|
|
"username": "example",
|
|
|
"password": "verySecure101",
|
|
|
"domain": "API School"
|
|
|
}
|
|
|
|
|
|
response = requests.post(f"{URL}/auth/getToken", data=data_auth)
|
|
|
|
|
|
result = response.json()
|
|
|
token = result["token"] # Get the bearer token from the json
|
|
|
|
|
|
|
|
|
data_app = {
|
|
|
"name": "Demo app",
|
|
|
"type": "code"
|
|
|
}
|
|
|
|
|
|
headers = {
|
|
|
"Authorization": f"Bearer {token}"
|
|
|
}
|
|
|
|
|
|
response = requests.post(f"{URL}/app/create", data=data_app, headers=headers)
|
|
|
|
|
|
result = response.json()
|
|
|
app_id = result["_id"] # Get the app id
|
|
|
|
|
|
print("App was successfully created!")
|
|
|
``` |
|
|
\ No newline at end of file |