Typical API route endpoint definitions
The commands supports the CRUD (Create, read, update, delete) operations.
The CRUD definitions for table items result in following API routes (example):
| Command | Endpoint | Comment |
|---|---|---|
| GET | v1/content/articles | Lists all articles with content items |
| GET | v1/content/articles/:id | Lists content items of article |
| POST | v1/content/articles | Creates new article with data |
| PATCH | v1/content/articles/:id | Writes parameters into selected article |
| DELETE | v1/content/articles/:id | Deletes selected article |
':id' has to be replaced with the article number
Attention: There is no **PUT** command support in Joomla
Get: Fetch articles
Curl:
curl -X GET \
-H "Accept: application/vnd.api+json" \
-H "X-Joomla-Token: YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles
Response:
{
"links": {
"self": "http://127.0.0.1/joommanual/api/index.php/v1/content/articles"
},
"data": [
{
"type": "articles",
"id": "11",
"attributes": {
"id": 11,
"asset_id": 138,
"title": "Typography",
"alias": "typography",
"state": 1,
"access": 1,
... more articles
"tags": {
"data": []
}
}
}
],
"meta": {
"total-pages": 1
}
}
Get: Fetch article by ID
Curl:
curl -X GET \
-H "Accept: application/vnd.api+json" \
-H "X-Joomla-Token: YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles/11
Response:
{
"links": {
"self": "http://127.0.0.1/joommanual/api/index.php/v1/content/articles"
},
"data": [
{
"type": "articles",
"id": "11",
"attributes": {
"id": 11,
"asset_id": 138,
"title": "Typography",
"alias": "typography",
"state": 1,
"access": 1,
... more
},
"tags": {
"data": []
},
"modified_by": {
"data": {
"type": "users",
"id": "944"
}
}
}
}
}
Post: Create article
Curl:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"title":"My new article","catid":2,"articletext":"Hello world","language":"*"}' \
-H "Accept: application/vnd.api+json" \
-H "X-Joomla-Token: YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles
Response:
{
"links": {
"self": "http://127.0.0.1/joommanual/api/index.php/v1/content/articles"
},
"data": [
{
"type": "articles",
"id": "11",
"attributes": {
"id": 11,
"asset_id": 138,
"title": "My new article",
"alias": "my-new-article",
"state": 1,
"access": 1,
... more
},
"tags": {
"data": []
},
"modified_by": {
"data": {
"type": "users",
"id": "944"
}
}
}
}
}
Patch: Update article by ID
Curl:
curl -X PATCH \
-H "Content-Type: application/json" \
-d '{"title":"Last article","catid":2}' \
-H "Accept: application/vnd.api+json" \
-H "X-Joomla-Token: YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles/11
Response:
{
"links": {
"self": "http://127.0.0.1/joommanual/api/index.php/v1/content/articles"
},
"data": [
{
"type": "articles",
"id": "11",
"attributes": {
"id": 11,
"asset_id": 138,
"title": "Last article",
"alias": "my-new-article",
"state": 1,
"access": 1,
... more
},
"tags": {
"data": []
},
"modified_by": {
"data": {
"type": "users",
"id": "944"
}
}
}
}
}
Delete: Delete article by ID
Curl:
curl -X DELETE \
-H "Accept: application/vnd.api+json" \
-H "X-Joomla-Token: YOUR_API_TOKEN" \
"http://127.0.0.1/joommanual/api/index.php/v1/content/articles/4"
Response:
%
Before deleting the article needs to be in trash state. Patch article with publish=-2
Not CRUDE endpoints:
Most endpoint are accessing a db table. This makes the CRUDE endpoints easy to program.
Others
- media
- custom fields
Custom Field endpoints
api/index.php/v1/fields/content/articles
Custom fields definitions have their own endpoints. These endpoints return the definitions of the fields (name, type, options), not the values stored in articles.
| .../v1/fields/content/articles | List all custom fields defined for articles |
| .../v1/fields/content/articles/7 | Get one custom field by ID |
| .../v1/fields/groups/content/articles | List custom field groups for articles |
| .../v1/fields/groups/content/articles/3 | Get one field group by ID |
POST, PATCH and DELETE commands are supported, so they can be created, changed or deleted