API Integration
It is possible to connect with your Qore application through an API.
By default, Qore front-end connects with the back-end in a stateful way, meaning a session will be kept alive, and when the session expires, the user will be logged out. However, this is not always possible, since a stateful session is tightly connected with a domain. This documentation page describes how you can connect Qore without having a session (stateless) via a Bearer Token.
Note that not every endpoint is described here, more documentation will be added in future requests.
Quickstart
We are maintaining a Postman Collection with example API requests, if you want to have access to this collection, please contact a Qore maintainer.
Authorization
To get started, you will have to create an authorization token.
Generate authorization token
Log in into your Qore application and manually go to /api_tokens
in the front-end.
When you're working on localhost, the full route is most likely: http://127.0.0.1:8080/api_tokens
On the right side you can create a token (fill in a device_name
and optional expiration_date
).
Once you've generated a token, copy it (it will only be visible once).
Authenticate with authorization token
You can now start doing requests. Let's start with a request to /api/me
.
GET {{host}}/api/me
# Authorization
Bearer {{ auth_token }}
All example requests below will expect the Bearer Token to be added in the header.
Endpoints
Once authenticated, you can do the following request to see all available endpoints:
GET {{host}}/api/endpoints
These are all routes that exists within the api
middleware.
Resources
Below is described how you can retrieve and manipulate resource data.
Index (table)
GET {{host}}/api/resources/{resource_name}/table/{table_name}
The table_name
should be the same as resource_name
if you don't have a separate table registered.
As you can see, it will also return metadata such as columns. You can reduce response data by setting the following header:
Prefer : return:minimal
To filter, sort etc. on table columns, you can add a JSON
body:
{
"tab": "Mijn registraties",
"search_columns": {
"name": "e",
"organization": [1]
},
"sort_column": "name",
"sort_direction": "ascending",
"per_page": 100,
"page": 1
}
Please keep in mind that these values only work on fields that are visible in the table by default.
Detail
GET {{host}}/api/resources/{resource_name}/{id}
You can reduce response data by setting the following header:
Prefer : return:minimal
Create
POST {{host}}/api/resources/{resource_name}
You can either send json
or FormData
. The easiest way is to send json
, however with FormData
you can also upload files.
With JSON as body:
{
"name": "Name",
"email": "example@qlic.nl",
"tenants": [1]
}
Update
PUT {{host}}/api/resources/{resource_name}/{id}
If you're posting with FormData
, please make sure to use POST
and add: _method
:PUT
to your request payload.
With JSON as body:
{
"name": "Name",
"email": "example@qlic.nl",
"tenants": [1]
}
You can also update a single field (inline):
PUT {{host}}/api/resources/{resource_name}/{id}/inline/{field_name}
With JSON as body:
{
"name": "New name"
}
Delete (and actions)
POST {{host}}/api/resources/{resource_name}/actions/{action_name}/{id}
Where the {action_name}
should be delete_resource
when deleting the resource.
Activity logs
GET {{host}}/api/resources/{resource_name}/logs/{id}
Field options
When you have a field with select options (e.g. BelongsTo
) you can retrieve these options:
GET {{host}}/api/resources/{resource_name}/field/{field_name}/options
In some cases, you only want the available options based on certain conditions in the form. When this is the case, you need to make a request to the create/edit form instead:
GET {{host}}/api/resources/{resource_name}/create
Header: Prefer : return:minimal
Body (JSON):
{
"initial_request": false,
"field": "issue",
"state": {
"project": 1
},
"action": {
"name": "reloadRelatedOptions"
}
}
The payload above means that the options
for the field issue
should be loaded based on the state
.
In the response, you will find the options here:
"issue": {
"relatedOptions": [
{
"group": "Geen Milestone",
"disable": true
},
{
"label": "Hello taak 1",
"description": "PTA.23.0001",
"value": 1
}
]
}
Global search
GET {{host}}/api/global-search?query=e
More examples
Please find the Postman collection for more examples.