Portal-api
Portal API
The portal.robotsindeklas.nl provides a public API that can be used to automate certain tasks, e.g. creating new users and sharing standardized apps with them.
1. Introduction
1.1 Preparation
Before hands-on coding your application, you need to:
- Set up your development environment
- Have an account on portal.robotsindeklas.nl
2. REST API
2.1 The endpoint
The base URL for our REST API calls looks like this:
https://portal.robotsindeklas.nl/API/v1
2.2 Request methods
Please note that you should use the POST method for your request unless indicated otherwise.
2.3 Parameters
To send the required parameters for your request, please put them in the body of the request in JSON format.
2.4 Requesting token
To access the public API, we first have to authorize ourselves by getting a valid token to perform the desired actions. A token can be requested by making a POST request to:
https://portal.robotsindeklas.nl/API/v1/auth/getToken
In the body of the request, enter the following details:
{
"username": "USERNAME",
"password": "PASSWORD",
"domain": "DOMAIN"
}
Example:
{
"username": "Pietje",
"password": "Password123!",
"domain": "API School"
}
If a valid combination of username, password, and the domain is given; a bearer token is returned which can be used to authorize the public API requests.
2.5 Items
The logic of the API is divided into a number of items. Each item described a group on which we can perform certain actions. For example, with the item App we can create new apps in portal.robotsindeklas.nl or copy and/or share existing apps with your users.
2.6 Response status code
The API can return a few different status codes depending on if the call was successful or not. In general, a status of 200 means that the call succeeded and anything else that it failed. A few hints on where to begin troubleshooting can be found in the table below.
Status Code | Description |
---|---|
200 Ok | The request was accepted and successfully handled |
400 Bad Request | The request sent is incorrect. Please make sure the parameters and their values are correct. |
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. Currently, this number is set to a maximum of 10 requests per action. |
500 Unexpected Error | An unexpected error has occurred. |
Examples
The most common library in Python to make API requests is the library requests
. 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
The following code will make a request to obtain a valid Bearer token and then create a new app with the name 'Demo app':
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", json=data_auth)
result = response.json()
token = result["token"] # Get the bearer token from the json
AUTH = {
"Authorization": f"Bearer {token}"
}
data_app = {
"name": "Demo app",
"type": "code"
}
response = requests.post(f"{URL}/app/create", json=data_app, headers=AUTH)
result = response.json()
app_id = result["_id"] # Get the app id
print("App was successfully created!")