-
Notifications
You must be signed in to change notification settings - Fork 29
API
Benjamin Jonard edited this page Jun 9, 2024
·
4 revisions
You can access a basic REST API documentation on /api
This API is built using API Platform
To use it you need get a JWT token using your username and your password by calling
POST /api/authentication_token
{
"username": "johndoe",
"password": "password"
}
Then for every requests to the API, add the following header :
Authorization: Bearer the_jwt_token
- Most endpoints are using
application/json
for the content type - POST endpoints supporting file upload are using
multipart/form-data
- PATCH endpoints are using
application/merge-patch+json
The content-type to use is specified in the documentation found on /api
When adding a reference to another object using an id, using an IRI is required (the IRI is the same as the GET route of this object)
In the example below, we are adding a new Field to a Template :
POST /api/fields
{
"name": "Publisher",
"position": 0,
"type": "text",
"template": "/api/templates/fdae6221-1c18-48f4-b5e0-646ffe652949"
}
When using PUT endpoints, you have to send the whole data
PUT /api/fields/31baaf77-9a0d-4ec4-b1e4-442ba46873c8
{
"name": "New Publisher",
"position": 0,
"type": "text",
"template": "/api/templates/fdae6221-1c18-48f4-b5e0-646ffe652949"
}
On the contrary, PATCH endpoints allow to update only the required data
PATCH /api/fields/31baaf77-9a0d-4ec4-b1e4-442ba46873c8
{
"name": "New Publisher"
}
I would recommend using PUT instead of PATCH
- No access to admin features
- No access to sharing features (you can't see someone else content)
- Uploads only work for POST requests
Type | Examples |
---|---|
text , textarea , link
|
a string: Example value
|
country |
2 letters country code: FR
|
date |
Year-Mounth-Day format: 2024-06-10
|
rating |
Number between 1 and 10. 1 for half a star, 2 for one star, 3 for one and a half etc... |
number |
A number -> 3 , -5 , 1.25
|
list |
Json string, double quotes are mandatory: ["Value 1","Value 2","Value 3"]
|
choice-list |
Same as list, but remember to fill choice_list_id
|
checkbox |
0 or 1
|
image , sign
|
null , use image upload endpoint to upload the image after creating the data field |
file |
null , use file upload endpoint to upload the file after creating the data field |
video |
null , use video upload endpoint to upload the video after creating the data field |