Items
List Items in a Collection
Returns a list of the items in the given collection.
Query Parameters
Unique identifier of the collection the item resides in.
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
How many items to skip when fetching data.
Cursor for use in pagination. Often used in combination with limit.
What metadata to return in the response.
How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Saves the API response to a file. Accepts one of csv, csv_utf8, json, xml, yaml.
Retrieve an item's state from a specific Content Version. The value corresponds to the "key" of the Content Version.
Retrieve the raw delta of a Content Version item instead of the full merged item.
Retrieve relational items excluding reverse relations when using wildcard fields.
Aggregate functions allow you to perform calculations on a set of values. Accepts one or more of count, countDistinct, countAll, sum, sumDistinct, avg, avgDistinct, min, max.
Grouping allows for running the aggregation functions based on a shared value. Accepts an array of field names.
Deep allows you to set any of the other query parameters on a nested relational dataset. Use underscore-prefixed parameter names.
Alias allows you to rename fields in the response payload. The key is the new name, the value is the original field name.
Responses
import { createDirectus, rest, readItems } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readItems('collection_name', query_object));
{
"data": [
{}
]
}Create Multiple Items
Create new items in the given collection.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
How many items to skip when fetching data.
How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
What metadata to return in the response.
Request Body
Responses
Returns the total item count of the collection you're querying.
Returns the item count of the collection you're querying, taking the current filter/search parameters into account.
import { createDirectus, rest, createItems } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createItems(collection_name, item_object_array));
{
"data": [
{}
],
"meta": {}
}Delete Multiple Items
Delete multiple items at the same time.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
Responses
import { createDirectus, rest, deleteItems } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const resultByKeys = await client.request(deleteItems(collection_name, item_id_array));
const resultByQuery = await client.request(deleteItems(collection_name, query_object));
Update Multiple Items
Update multiple items at the same time.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
Responses
Returns the total item count of the collection you're querying.
Returns the item count of the collection you're querying, taking the current filter/search parameters into account.
import { createDirectus, rest, updateItems } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const resultByKeys = await client.request(updateItems(collection_name, item_id_array, partial_item_object));
const resultByQuery = await client.request(updateItems(collection_name, query_object, partial_item_object));
{
"data": [
{}
],
"meta": {}
}Create an Item
Create a new item in the given collection.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
What metadata to return in the response.
Responses
import { createDirectus, rest, createItem } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createItem(collection_name, item_object));
{
"data": {}
}Retrieve an Item
Retrieves an item in a given collection.
Query Parameters
Unique identifier for the object.
Collection of which you want to retrieve the items from.
Retrieve an item's state from a specific Content Version. The value corresponds to the "key" of the Content Version.
Control what fields are being returned in the object.
What metadata to return in the response.
Responses
import { createDirectus, rest, readItem } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readItem(collection_name, item_id, query_object));
{
"data": {}
}Delete an Item
Delete an existing item.
Query Parameters
Unique identifier of the item.
Collection of which you want to retrieve the items from.
Responses
import { createDirectus, rest, deleteItem } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteItem(collection_name, item_id));
Update an Item
Update an existing item.
Query Parameters
Unique identifier of the item.
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
What metadata to return in the response.
Responses
import { createDirectus, rest, updateItem } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateItem(collection_name, item_id, partial_item_object));
{
"data": {}
}Retrieve a Singleton Item
Retrieve the singleton item from the given collection. Unlike regular collections, a singleton returns a plain item object rather than an array of items.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
What metadata to return in the response.
Retrieve an item's state from a specific Content Version. The value corresponds to the "key" of the Content Version.
Retrieve the raw delta of a Content Version item instead of the full merged item.
Deep allows you to set any of the other query parameters on a nested relational dataset. Use underscore-prefixed parameter names.
Alias allows you to rename fields in the response payload. The key is the new name, the value is the original field name.
Responses
import { createDirectus, rest, readSingleton } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readSingleton('collection_name', query_object));
{
"data": {}
}Update a Singleton Item
Update the singleton item in the given collection. Unlike batch updates for regular collections, the request body should be a plain item object rather than a keyed batch payload.
Query Parameters
Collection of which you want to retrieve the items from.
Control what fields are being returned in the object.
What metadata to return in the response.
Responses
import { createDirectus, rest, updateSingleton } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateSingleton('collection_name', partial_item_object));
{
"data": {}
}