StatamicApiParamsBase

Base parameters available for most Statamic API requests.

Type Definition

type 
StatamicApiParamsBase
<
T
extends
Record
<string, any> =
StatamicApiEntryDefaultFields
> = {
/** * The top level fields that should be included in the response. * * @example * ```ts * { fields: ["id", "title", "content"] } * ``` */
fields
: (keyof
T
)[];
/** * Filters results based on the specified field conditions. * * You may specify filters following the pattern: * `{field_name}:{condition}={value}` * * Union type for filter keys: * - Plain field name: `{field}` → will apply the `"is"` condition by default. * - Field with condition: `{field}:{condition}` → applies the specified condition. * * @see {@link https://statamic.dev/conditions#syntax|Statamic string conditions syntax} * @example <caption>Filter where title contains "awesome" and featured is true</caption> * ```ts * { filter: { "title:contains": "awesome", featured: true } } * ``` */
filter
: {
[
K
in
StatamicApiFieldOrCondition
<
T
>]?: any;
}; /** * Sorts results based on the specified fields. * Prefix with hyphen for descending order. * * Fields can be prexied with a hyphen to sort descending. * * @example <caption>Single field</caption> * ```ts * { sort: "fieldName" } * ``` * @example <caption>Multiple fields</caption> * ```ts * { sort: "fieldName,anotherfield" } * ``` * @example <caption>Multiple fields in custom order</caption> * ```ts * { sort: "fieldNameOne,-fieldNameTwo,fieldNameThree" } * ``` * @example <caption>Reverse order</caption> * ```ts * { sort: "-fieldName" } * ``` * @example <caption>Nested field</caption> * ```ts * { sort: "fieldName->nestedFieldName" } * ``` */
sort
: string;
/** * The number of results to fetch per page. * @defaultValue 25 */
limit
: number;
/** * The page number to fetch. * @defaultValue 1 */
page
: number;
/** * The site to fetch data from. */
site
: string;
/** * The token to use for live preview mode. */
token
: string;
}