10 KiB
Tainacan Application Programming Interface
Brief Description
A REST API for Tainacan Plugin. This API uses the Wordpress REST API.
Routes and Endpoints
Summary
- Collections
- Items
- Fields
- Field Types
- Item Metadata
- Taxonomies
- Filters
- Filter Types
- Terms
- Logs
- Others
Collections
-
Route
wp-json/tainacan/v2/collections/(?P<collection_id>[\d]+)
-
Endpoints:
-
GET (Fetch a collection)
-
DELETE (Delete or Trash a collection and all your dependencies)
To delete pass in body of a requisition the parameter
is_permanently
as true. To only trash pass false. -
PATCH or PUT (Update a collection)
Example of JSON passed in body for updating a collection:
-
-
{
"name": "string",
"description": "string",
...
}
-
Route
wp-json/tainacan/v2/collections
-
Endpoints:
-
GET (Fetch all collections)
-
POST (Create a collection).
Example of JSON passed in body for creating a collection:
-
-
{
"name": "string",
"description": "string",
"status": "string",
"order": "string",
"parent": "integer",
"slug": "string",
"default_orderby": "string",
"default_order": "string",
"columns": "string",
"default_view_mode": "string"
}
Items
-
Route
wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/items
-
Endpoints:
-
GET (Fetch all items from a collection)
-
POST (Create a item in a collection)
Example of JSON passed in body for creating a item:
-
-
{
"title": "string",
"description": "string",
"status": "string",
"terms": ["integer", "integer", ...]
}
-
Route
wp-json/tainacan/v2/items/(?P<item_id>[\d]+)
-
Endpoints:
-
GET (Fetch a item)
-
DELETE (Delete or Trash a item and all your dependencies)
To delete pass in body of a requisition the parameter is_permanently as true. To only trash pass false.
-
PATCH or PUT (Update a item)
Example of JSON passed in body for updating a item:
-
-
{
"title": "string",
"description": "string",
"terms": ["integer", "integer", ...]
...
}
Fields
-
Route
wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/fields
- Endpoints:
-
GET (Fetch all collection field)
-
POST (Create a field in collection and all it items)
In body of requisition pass a JSON with the attributes of field like:
-
- Endpoints:
{
"name": "string",
"description": "string",
"field_type": "string",
"order": "string",
"parent": "integer",
"required": "string",
"collection_key": "string",
"multiple": "string",
"cardinality": "string",
"mask": "string",
"default_value": "string",
"field_type_options": "string",
}
-
Route
wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/fields/(?P<field_id>[\d]+)
-
Endpoints:
-
GET (Fetch a field from a collection or Fetch all field values)
To fetch all field values from a field of a collection in all it items, pass a query like
?fetch=all_field_values
-
PATCH or PUT (Update a field in a collection and all it items)
In body of requisition pass a JSON with the attributes you need to update, like:
-
-
{
"name": "string",
"description": "string",
}
-
Route
wp-json/tainacan/v2/fields
-
Endpoints:
-
GET (Fetch all default fields)
-
POST (Create a default field)
In body of requisition pass a JSON with the attributes of field.
-
-
-
Route
wp-json/tainacan/v2/fields/(?P(<field_id>[\d]+))
-
Endpoints:
-
DELETE (Trash a default field)
-
PATCH or PUT (Update a default field)
In body of requisition pass a JSON with the attributes you need to update.
-
-
Field Types
-
Route
wp-json/tainacan/v2/field-types
-
Endpoint:
- GET (Fetch all field types)
-
Item Metadata
-
Route
wp-json/tainacan/v2/item/(?P<item_id>[\d]+)/metadata/(?P<metadata_id>[\d]+)
-
Endpoints:
-
PATCH or PUT (Set value of a metadata)
In body of requisition pass a JSON with values of metadata, like:
-
-
{
"values": ["any", "type"]
}
-
Route
wp-json/tainacan/v2/item/(?P<item_id>[\d]+)/metadata
-
Endpoint:
- GET (Fetch all item metadata, with it values)
-
Taxonomies
-
Route
wp-json/tainacan/v2/taxonomies
-
Endpoints:
-
GET (Fetch all taxonomies)
-
POST (Create a taxonomy)
Example of JSON passed in body for creating a taxonomy:
-
-
{
"name": "string",
"description": "string",
"status": "string",
"parent": "string",
"slug": "string",
"allow_insert": "string",
"collections_ids": "array"
}
-
Route
wp-json/tainacan/v2/taxonomies/(?P<taxonomy_id>[\d]+)
-
Endpoints:
-
GET (Fetch a taxonomy)
-
DELETE (Delete or trash a taxonomy)
To delete pass in body of requisition the parameter is_permanently as true. To only trash pass false.
-
PATCH or PUT (Update a taxonomy)
Example of JSON passed in body for updating a taxonomy:
-
-
{
"name": "string",
"description": "string",
...
}
-
Route
wp-json/tainacan/v2/taxonomies/(?P<taxonomy_id>[\d]+)/collection/(?P<collection_id>[\d]+)
-
Endpoints:
- PATCH or PUT (Add a Collection in a Taxonomy)
-
Filters
-
Route
wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/field/(?P<field_id>[\d]+)/filters
-
Endpoints:
-
POST (Create a filter)
Example of JSON passed in body for creating a filter:
-
-
{
"filter_type": "string",
"filter": {
"name": "string",
"description": "string",
...
}
}
-
Route
wp-json/tainacan/v2/filters/(?P<filter_id>[\d]+)
-
Endpoints:
-
GET (Fetch a filter)
-
DELETE (Delete or trash a filter)
To delete pass in body of requisition the parameter is_permanently as true. To only trash pass false.
-
PATCH or PUT (Update a filter)
Example of JSON passed in body for updating a filter:
-
-
{
"name": "string",
...
}
-
Route
wp-json/tainacan/v2/filters
-
Endpoints:
-
GET (Fetch all repository filters)
-
POST (Create a filter in repository. Without field and collection associations)
Example of JSON passed in body for creating a filter:
-
-
{
"filter_type": "string",
"filter": {
"name": "string",
"description": "string",
...
}
}
-
Route
wp-json/tainacan/v2/collection/(?P<collection_id>[\d]+)/filters
-
Endpoints:
-
GET (Fetch all collection filters)
-
POST (Create a filter in a collection, without field association)
Example of JSON passed in body for creating a filter:
-
-
{
"filter_type": "string",
"filter": {
"name": "string",
"description": "string",
...
}
}
Filter Types
-
Route
wp-json/tainacan/v2/filter-types
-
Endpoint:
- GET (Fetch all filter types)
-
Terms
-
Route
wp-json/tainacan/v2/taxonomy/(?P<taxonomy_id>[\d]+)/terms
-
Endpoints:
-
GET (Fetch all tems of a taxonomy)
-
POST (Create a term in a taxonomy)
Example of JSON passed in body for creating a term:
-
-
{
"name": "string",
"user": "int",
...
}
-
Route
wp-json/tainacan/v2/taxonomy/(?P<taxonomy_id>[\d]+)/terms/(?P<term_id>[\d]+)
-
Endpoints:
-
GET (Fecth a term of a taxonomy)
-
DELETE (Delete a term of a taxonoy)
-
PATCH or PUT (Update a term in a taxonomy)
Example of JSON passed in body for updating a term:
-
-
{
"name": "string",
...
}
Logs
-
Route
wp-json/tainacan/v2/logs
-
Endpoints:
- GET (Get all logs)
-
-
Route
wp-json/tainacan/v2/logs/(?P<log_id>[\d]+)
-
Endpoints:
- GET (Get a log)
-
Others
To Create, Read, Update or Delete Media or Users you can use the default routes of Wordpress.
See about Media in Media | REST API Handbook;
See about Users in Users | REST API Handbook.