Items
List all 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.
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. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Responses
GET /items/{collection}
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));
type Query {
<collection>: [<collection>]
}
{
"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. You can also use a ?
to sort randomly.
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.
POST /items/{collection}
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));
type Mutation {
create_<collection>_items(data: [create_<collection>_input]): [<collection>]
}
{
"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. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
Any of the following:
Primary keys of items to be deleted.
Object containing either keys
or query
to selected what items to update.
Responses
DELETE /items/{collection}
import { createDirectus, rest, deleteItems } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(deleteItems(collection_name, item_id_array));
//or
const result = await client.request(deleteItems(collection_name, query_object));
type Mutation {
delete_<collection>_items(ids: [ID!]!): delete_many
}
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. You can also use a ?
to sort randomly.
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.
PATCH /items/{collection}
import { createDirectus, rest, updateItems } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateItems(collection_name, item_id_array, partial_item_object));
type Mutation {
update_<collection>_items(ids: [ID!]!, data: [update_<collection>_input]): [<collection>]
}
{
"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.
Request Body
Responses
POST /items/{collection}
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));
type Mutation {
create_<collection>_item(data: create_<collection>_input): <collection>
}
{
"data": {}
}
Retrieve a Singleton
Retrieves a singleton of a given collection. The REST and GraphQL requests for singletons are the same as those used to Get Items but in contrast the response consists of a plain item object (the singleton) instead of an array of items.
Query Parameters
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
GET /items/{collection}/singleton
import { createDirectus, rest, readSingleton } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readSingleton(collection_name));
type Query {
<collection>(version: String): <collection>
}
type Query {
<collection>_by_version(version: String!): <collection_version_raw>
}
{
"data": {}
}
Update Singleton
Update a singleton item. The REST and GraphQL requests for singletons are the same as those used to Update Multiple Items but in contrast the request should consist of the plain item object.
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.
Request Body
Responses
PATCH /items/{collection}/singleton
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));
type Mutation {
update_<collection>_items(data: [update_<collection>_input]): [<collection>]
}
{
"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
GET /items/{collection}/{id}
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));
type Query {
<collection>_by_id(id: ID!, version: String): <collection>
}
type Query {
<collection>_by_version(id: ID!, version: String!): <collection_version_raw>
}
{
"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
DELETE /items/{collection}/{id}
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));
type Mutation {
delete_<collection>_item(id: ID!): delete_one
}
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.
Request Body
Responses
PATCH /items/{collection}/{id}
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));
type Mutation {
update_<collection>_item(id: ID!, data: update_<collection>_input!): <collection>
}
{
"data": {}
}