Gobierto Vocabularies / Terms
List vocabulary terms
The way to get a list of terms in a vocabulary is to inspect the terms
attribute in a vocabulary or call the vocabulary terms endpoint
GET
/api/v1/vocabularies/<vocabluary_id>/terms
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Example of response:
{
"data": [
{
"id": "21549",
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"en": "New term 1",
"es": "Nuevo termino 1"
},
"description_translations": {
"en": "New term 1 desc",
"es": "Nuevo termino 1 desc"
},
"slug": "term-slug",
"position": 0,
"level": 0,
"term_id": null,
"parent_external_id": null,
"parent_id": null,
"external_id": "E0001"
}
},
{
"id": "21550",
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"en": "New term 1.1",
"es": "Nuevo termino 1.1"
},
"description_translations": {
"en": "New term 1.1 desc",
"es": "Nuevo termino 1.1 desc"
},
"slug": "term-slug-11",
"position": 0,
"level": 1,
"term_id": 21549,
"parent_external_id": "E0001",
"parent_id": "E0001",
"external_id": "E0001.1"
}
}//,
//{ ... },
//...
]
}
Show a vocabulary term
GET
/api/v1/vocabularies/<vocabluary_id>/terms/<term_id>
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Example of response:
{
"data": {
"id": "21549",
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"en": "New term 1",
"es": "Nuevo termino 1"
},
"description_translations": {
"en": "New term 1 desc",
"es": "Nuevo termino 1 desc"
},
"slug": "term-slug",
"position": 0,
"level": 0,
"term_id": null,
"parent_external_id": null,
"parent_id": null,
"external_id": "E0001"
}
}
}
Show a new vocabulary term
This endpoint provides a template of data expected to be sent to create a single term of a vocabulary.
GET
/api/v1/vocabularies/<vocabluary_id>/terms/new
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Example of response:
{
"data": {
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"es": null,
"en": null,
"ca": null
},
"description_translations": {
"es": null,
"en": null,
"ca": null
},
"slug": null,
"position": 0,
"level": 0,
"term_id": null,
"parent_external_id": null,
"parent_id": null,
"external_id": null
}
}
}
Create a new vocabulary term
The way to create a new term in the vocabulary is to send the term in the terms
attribute of the vocabulary update request. or make a request to the vocabulary create term endpoint
POST
/api/v1/vocabularies/<vocabluary_id>/terms
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Example body request:
{
"data": {
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"es": "Otro término",
"en": "Another term",
"ca": "Otro terme"
},
"description_translations": {
"es": "Otro término",
"en": "Another term",
"ca": "Otro terme"
},
"slug": "another-term",
"position": 4,
"parent_id": "E0001",
"external_id": "E0001.2"
}
}
}
Example of response:
{
"data": {
"id": "21554",
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"es": "Otro término",
"en": "Another term",
"ca": "Otro terme"
},
"description_translations": {
"es": "Otro término",
"en": "Another term",
"ca": "Otro terme"
},
"slug": "another-term",
"position": 4,
"level": 1,
"term_id": 21549,
"parent_external_id": "E0001",
"parent_id": "E0001",
"external_id": "E0001.2"
}
}
}
Update a vocabulary term
The way to update a term in the vocabulary is to send the term in the terms
attribute of the vocabulary update request or make a request to the update term endpoint
PUT
/api/v1/vocabularies/<vocabluary_id>/terms/<term_id>
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Example body request
{
"data": {
"attributes": {
"name_translations": {
"es": "Otro término modificado"
},
"description_translations": {
"en": "Another term with description updated only in english"
},
"slug": "another-term-updated",
"position": 6,
"parent_id": "E0001.1",
"external_id": "E0001.1.1"
}
}
}
Example of response:
{
"data": {
"id": "21554",
"type": "gobierto_common-terms",
"attributes": {
"name_translations": {
"es": "Otro término modificado"
},
"description_translations": {
"en": "Another term with description updated only in english"
},
"slug": "another-term-updated",
"position": 6,
"level": 2,
"term_id": 21550,
"parent_external_id": "E0001.1",
"parent_id": "E0001.1",
"external_id": "E0001.1.1"
}
}
}
Delete a vocabulary term
DELETE
/api/v1/vocabularies/\<vocabluary_id>/terms/<term_id>
Deletes a term in a vocabulary. The request must include a valid token of an authorized admin.
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
The request does not include a body.
Response:
- If the token is invalid or the admin is not allowed to create term: JSON with
Unauthorized
orModule not allowed
with status401 Unauthorized
- If the resource could be deleted it returns a successfull
204 No Content
status code.
Updated about 1 year ago