### Basic Image Transformation Request Source: https://docs.decc0s.com/examples/assets/transformations This example shows a basic GET request to transform an asset. It specifies target width, height, fitting method, output format, and compression quality. ```bash GET /assets/{id}?width=800&height=600&fit=cover&format=webp&quality=80 ``` -------------------------------- ### Metadata API Request Example Source: https://docs.decc0s.com/query-guide Illustrates how to request additional metadata, such as `filter_count` and `total_count`, by including the `meta=*` parameter in the API request. This metadata is essential for implementing features like pagination. ```bash GET /items/codex?meta=*&limit=10 ``` -------------------------------- ### Retrieve All File Metadata (Bash) Source: https://docs.decc0s.com/examples/files/get-metadata Fetches all available metadata for a given file using its UUID. This is a direct API call example. No specific dependencies are required beyond a valid file ID. ```bash GET /files/a1b2c3d4-e5f6-7890-1234-abcdef123456 ``` -------------------------------- ### Fetch Item with Moltbot Data (Bash) Source: https://docs.decc0s.com/codex This example shows how to fetch an item, specifically including the 'moltbot' field which contains versioned character data. It demonstrates a basic GET request to the API. ```bash curl "${API_BASE_URL}/items/codex/1?fields=id,name,moltbot" ``` -------------------------------- ### List Codex Items - Go Source: https://docs.decc0s.com/api/codex This Go snippet shows how to fetch a list of codex items using the `net/http` package. It performs a GET request to the /items/codex endpoint and prints the response body. This example does not include any query parameters. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("https://api.decc0s.com/items/codex") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Files Examples Source: https://docs.decc0s.com/examples Provides examples for accessing and filtering stored files, including listing files, filtering by type, retrieving metadata, and querying recent uploads. ```APIDOC ## Common File Queries ### List files **Method**: GET **Endpoint**: `/files?fields=id,title,type&limit=10` ### Images only **Method**: GET **Endpoint**: `/files?filter[type][_starts_with]=image/` ### Recent uploads **Method**: GET **Endpoint**: `/files?sort=-created_on&limit=5` ### Get metadata **Method**: GET **Endpoint**: `/files/{uuid}` ``` -------------------------------- ### Get Specific Codex Item Source: https://docs.decc0s.com/getting-started Retrieves a single codex item by its ID. ```APIDOC ## GET /items/codex/{id} ### Description Retrieves a single codex item by its unique identifier. ### Method GET ### Endpoint /items/codex/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the codex item. #### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to include in the response. - **meta** (string) - Optional - Request metadata. Use `?meta=*` to include all metadata. ### Request Example ```bash curl "https://your-api-base-url/items/codex/1?fields=id,name" ``` ### Response #### Success Response (200) - **data** (object) - The codex item object. - **meta** (object) - Optional metadata about the response. #### Response Example ```json { "data": { "id": 1, "name": "Korka" } } ``` ``` -------------------------------- ### Fetch Codex Items Source: https://docs.decc0s.com/getting-started Retrieves a list of codex items. This is a simple GET request to the /items/codex endpoint. ```APIDOC ## GET /items/codex ### Description Retrieves a list of all codex items. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **filter** (object) - Optional - Used for filtering results using Directus filter syntax. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. - **meta** (string) - Optional - Request metadata such as total counts. Use `?meta=*` to include all metadata. ### Request Example ```bash curl "https://your-api-base-url/items/codex?fields=id,name,description" ``` ### Response #### Success Response (200) - **data** (array) - An array of codex item objects. - **meta** (object) - Optional metadata about the response, such as `filter_count` and `total_count`. #### Response Example ```json { "data": [ { "id": 1, "name": "Korka", "ancestor": "Slovenian king", "description": "A contemplative curator..." } ] } ``` ``` -------------------------------- ### Image Transformation Examples Source: https://docs.decc0s.com/examples/assets/transformations Demonstrates various image transformation use cases including resizing to a specific width, maintaining aspect ratio with specified dimensions and fit, converting to WebP with quality settings, and creating square thumbnails. ```bash GET /assets/{id}?width=400 ``` ```bash GET /assets/{id}?width=800&height=600&fit=contain ``` ```bash GET /assets/{id}?format=webp&quality=85 ``` ```bash GET /assets/{id}?width=200&height=200&fit=cover ``` -------------------------------- ### GET /items/codex - Bracket Notation Example Source: https://docs.decc0s.com/examples/advanced/complex-filters This example shows an alternative way to specify simple AND conditions using bracket notation for the filter parameters. ```APIDOC ## GET /items/codex - Bracket Notation ### Description Retrieves items using bracket notation for filter parameters, equivalent to a simple AND condition. ### Method GET ### Endpoint /items/codex ### Query Parameters - **filter[id][_gte]** (integer) - Required - Filter for item ID greater than or equal to the specified value. - **filter[name][_nnull]** (boolean) - Required - Filter for items where the name is not null. - **fields** (string) - Optional - Comma-separated list of fields to return. Example: `id,name` - **limit** (integer) - Optional - Maximum number of results to return. Example: `10` ### Request Example ```bash GET /items/codex?filter[id][_gte]=1&filter[name][_nnull]=true&fields=id,name&limit=10 ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the item. - **name** (string) - The name of the item. #### Response Example ```json { "id": 1, "name": "Bracket Item" } ``` ``` -------------------------------- ### Resize Asset with Preset Source: https://docs.decc0s.com/files This example shows how to resize an asset using a predefined preset, identified by a key. The 's512' key likely corresponds to a specific image size or quality setting. This is useful for consistent image handling across the application. ```bash curl "${API_BASE_URL}/assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?key=s512" ``` -------------------------------- ### GET /items/codex - OR Operator Example Source: https://docs.decc0s.com/examples/advanced/complex-filters This example shows how to use the `_or` logical operator to find items where either the ID is exactly 1 OR the ID is exactly 2. ```APIDOC ## GET /items/codex - OR Operator ### Description Retrieves items where the ID is equal to 1 OR the ID is equal to 2. ### Method GET ### Endpoint /items/codex ### Query Parameters - **filter** (string) - Required - JSON string representing filter conditions using `_or`. Example: `{"_or":[{"id":{"_eq":1}},{"id":{"_eq":2}}]}` - **fields** (string) - Optional - Comma-separated list of fields to return. Example: `id,name` ### Request Example ```bash GET /items/codex?filter={"_or":[{"id":{"_eq":1}},{"id":{"_eq":2}}]}?fields=id,name ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the item. - **name** (string) - The name of the item. #### Response Example ```json { "id": 1, "name": "First Item" } ``` ``` -------------------------------- ### Assets Examples Source: https://docs.decc0s.com/examples/introduction Demonstrates image transformations and presets. Use preset transformations, apply custom width/height/format options, and leverage the Sharp API for advanced image processing. ```APIDOC ## Assets API Examples ### Description Examples for applying image transformations and using presets for assets. This includes resizing, format conversion, and custom transformations. ### Asset Transformations | Use Case | Example | |---|---| | Preset resize | `GET /assets/{id}?key=s512` | | Custom size | `GET /assets/{id}?width=800&height=600` | | Format conversion | `GET /assets/{id}?format=webp&quality=80` | | Rotate image | `GET /assets/{id}?transforms=[["rotate",90]]` | ``` -------------------------------- ### Asset Transformations Source: https://docs.decc0s.com/examples Illustrates how to use image transformations and presets for assets, including resizing, format conversion, and applying custom transformations. ```APIDOC ## Asset Transformations ### Preset resize **Method**: GET **Endpoint**: `/assets/{id}?key=s512` ### Custom size **Method**: GET **Endpoint**: `/assets/{id}?width=800&height=600` ### Format conversion **Method**: GET **Endpoint**: `/assets/{id}?format=webp&quality=80` ### Rotate image **Method**: GET **Endpoint**: `/assets/{id}?transforms=[["rotate",90]]` ``` -------------------------------- ### Error Handling Source: https://docs.decc0s.com/getting-started Describes the structure of error responses from the API. ```APIDOC ## Error Response Structure ### Description When an error occurs, the API returns a standardized error object. ### Response Example ```json { "errors": [ { "message": "Item not found", "extensions": { "code": "NOT_FOUND" } } ] } ``` ### Common Errors - **404 Not Found**: The requested resource does not exist. - **400 Bad Request**: Invalid query parameters or filter syntax. - **403 Forbidden**: Access denied, typically due to authentication requirements. ``` -------------------------------- ### Filter Operators: Starts With Source: https://docs.decc0s.com/llms-full Filter items where a specific field starts with a given string using the `_starts_with` operator. Useful for filtering by prefixes, like MIME types. ```http filter[type][_starts_with]=image/ ``` -------------------------------- ### Retrieve Images with Presets (Bash) Source: https://docs.decc0s.com/examples/assets/presets This snippet demonstrates how to retrieve images using pre-configured transformation presets via GET requests. The `key` parameter in the URL specifies the desired preset for resizing. Available presets include s128, s256, s512, and s1024, each resizing the image to a specific width while maintaining aspect ratio. ```bash GET /assets/{id}?key=s128 # Thumbnail (128px) GET /assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?key=s128 # Card preview (512px) GET /assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?key=s512 # Full size (1024px) GET /assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?key=s1024 ``` -------------------------------- ### GET /items/codex - Pagination with Limit and Offset Source: https://docs.decc0s.com/llms-full Retrieve paginated results using `limit` and `offset` parameters. Include `meta=*` to get total counts for building pagination UI. ```APIDOC ## GET /items/codex ### Description Retrieves paginated results using limit and offset, with optional metadata for total counts. ### Method GET ### Endpoint /items/codex ### Query Parameters - **limit** (integer) - Optional - Maximum items to return. Defaults to 100. - **offset** (integer) - Optional - Number of items to skip. Defaults to 0. - **meta** (string) - Optional - Include metadata. Use '*' for all metadata. Defaults to none. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name'. ``` -------------------------------- ### Codex Examples Source: https://docs.decc0s.com/examples Demonstrates common query patterns for the MOCA Codex knowledge base, including filtering by owner, searching, sorting, and pagination. ```APIDOC ## Common Codex Queries ### List items **Method**: GET **Endpoint**: `/items/codex?fields=id,name&limit=10` ### Get by ID **Method**: GET **Endpoint**: `/items/codex/1` ### Filter by owner **Method**: GET **Endpoint**: `/items/codex?filter[owner][_eq]=0x...` ### Search **Method**: GET **Endpoint**: `/items/codex?search=curator` ### Sort by date **Method**: GET **Endpoint**: `/items/codex?sort=-timestamp_created` ### Paginate **Method**: GET **Endpoint**: `/items/codex?limit=10&offset=20&meta=*` ``` -------------------------------- ### GET /items/codex - AND Operator Example Source: https://docs.decc0s.com/examples/advanced/complex-filters This example demonstrates using the `_and` logical operator to find items that satisfy multiple conditions simultaneously: ID greater than or equal to 100 AND name is not null. ```APIDOC ## GET /items/codex - AND Operator ### Description Retrieves items where the ID is greater than or equal to 100 AND the name is not null. ### Method GET ### Endpoint /items/codex ### Query Parameters - **filter** (string) - Required - JSON string representing filter conditions using `_and`. Example: `{"_and":[{"id":{"_gte":100}},{"name":{"_nnull":true}}]}` - **fields** (string) - Optional - Comma-separated list of fields to return. Example: `id,name` - **limit** (integer) - Optional - Maximum number of results to return. Example: `10` ### Request Example ```bash GET /items/codex?filter={"_and":[{"id":{"_gte":100}},{"name":{"_nnull":true}}]}?fields=id,name&limit=10 ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the item. - **name** (string) - The name of the item. #### Response Example ```json { "id": 101, "name": "Another Item" } ``` ``` -------------------------------- ### Transform Asset with Sharp API Operations Source: https://docs.decc0s.com/files This example demonstrates using the 'transforms' parameter to apply multiple transformations defined by Sharp API operations, such as rotation and blur. The operations are provided as a JSON array of arrays. This offers a flexible way to chain image manipulations. ```bash curl "${API_BASE_URL}/assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?transforms=[[\"rotate\",90],[\"blur\",10]]" ``` -------------------------------- ### GET /items/codex - Sort Alphabetically Source: https://docs.decc0s.com/llms-full Sort items by name in alphabetical order. ```APIDOC ## GET /items/codex ### Description Retrieves a list of codex items, sorted alphabetically by name. ### Method GET ### Endpoint /items/codex ### Query Parameters - **sort** (string) - Optional - Sort by 'name' for alphabetical order. - **limit** (integer) - Optional - Maximum number of items to return. Defaults to 10. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name'. ``` -------------------------------- ### Search Files by Keyword Source: https://docs.decc0s.com/files This command shows how to perform a general search for files containing a specific keyword ('profile'). This allows users to quickly find assets based on their titles, descriptions, or other searchable metadata. ```bash curl "${API_BASE_URL}/files?search=profile" ``` -------------------------------- ### GET /items/codex - Find Items With Description Source: https://docs.decc0s.com/llms-full This endpoint demonstrates how to find items that have a non-empty description. ```APIDOC ## GET /items/codex ### Description Find items that have a non-empty description. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **filter[description][_nempty]** (boolean) - Optional - Filter items where description is not empty. - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., id,name,description). - **limit** (integer) - Optional - Maximum number of items to return. ### Request Example ```bash GET /items/codex?filter[description][_nempty]=true&fields=id,name,description&limit=10 ``` ### Response #### Success Response (200) - **items** (array) - Array of codex items. #### Response Example ```json { "items": [ { "id": 1, "name": "Item 1", "description": "This is a description." } ] } ``` ``` -------------------------------- ### Flip and Sharpen Image (Bash) Source: https://docs.decc0s.com/examples/assets/sharp Example of applying both a vertical flip and a sharpen transformation to an image using the 'flip' and 'sharpen' operations. ```bash GET /assets/{id}?transforms=[["flip"],["sharpen"]] ``` -------------------------------- ### GET /items/codex - Combine Multiple Null Checks Source: https://docs.decc0s.com/llms-full This endpoint demonstrates how to find items with both name and description. ```APIDOC ## GET /items/codex ### Description Find items with both name and description. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **filter[name][_nnull]** (boolean) - Optional - Filter items where name is not null. - **filter[description][_nnull]** (boolean) - Optional - Filter items where description is not null. - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., id,name,description). - **limit** (integer) - Optional - Maximum number of items to return. ### Request Example ```bash GET /items/codex?filter[name][_nnull]=true&filter[description][_nnull]=true&fields=id,name,description&limit=10 ``` ### Response #### Success Response (200) - **items** (array) - Array of codex items. #### Response Example ```json { "items": [ { "id": 1, "name": "Item 1", "description": "This is a description." } ] } ``` ``` -------------------------------- ### Pagination Source: https://docs.decc0s.com/llms-full Control the number of results returned and the starting point for pagination using limit and offset parameters. ```APIDOC ## GET /items/codex ### Description Retrieves a paginated list of codex items. ### Method GET ### Endpoint /items/codex ### Query Parameters #### Path Parameters None #### Query Parameters - **limit** (integer) - Optional - The maximum number of results to return per page. Defaults to 10. - **offset** (integer) - Optional - The number of results to skip from the beginning. Used for pagination. ### Request Example ```bash GET /items/codex?limit=25&offset=50 ``` ### Response #### Success Response (200) - Returns a list of codex items for the specified page. #### Response Example ```json [ { "id": 51, "name": "Codex Item 51" }, { "id": 52, "name": "Codex Item 52" } ] ``` ``` -------------------------------- ### Image Transformations with Query Parameters (Bash) Source: https://docs.decc0s.com/llms-full Shows how to apply various image transformations like resizing, format conversion, and quality adjustments using query parameters in bash. This is useful for dynamic image manipulation. ```bash GET /assets/{id}?width=800&height=600&fit=cover&format=webp&quality=80 ``` ```bash GET /assets/{id}?width=400 ``` ```bash GET /assets/{id}?width=800&height=600&fit=contain ``` ```bash GET /assets/{id}?format=webp&quality=85 ``` ```bash GET /assets/{id}?width=200&height=200&fit=cover ``` -------------------------------- ### GET /items/codex - Metadata Options Source: https://docs.decc0s.com/query-guide Retrieve additional information about query results by including the `meta` parameter. ```APIDOC ## GET /items/codex ### Description Retrieves items and includes additional metadata about the query results. ### Method GET ### Endpoint /items/codex ### Query Parameters - **meta** (string) - Optional - Specifies the metadata to include. Accepted values: - `*`: Include all metadata. - `total_count`: Include the total number of items in the collection. - `filter_count`: Include the number of items matching the current filter. ### Example ```bash GET /items/codex?meta=*&limit=10 ``` ### Response Example ```json { "data": [...], "meta": { "filter_count": 42, "total_count": 100 } } ``` ``` -------------------------------- ### Query Files (List, Filter by Type, Sort) Source: https://docs.decc0s.com/examples/introduction Shows how to list files stored in the system, filter them by MIME type (e.g., images), and retrieve recent uploads sorted by upload date. This includes fetching file metadata using its UUID. ```http GET /files?fields=id,title,type&limit=10 GET /files?filter[type][_starts_with]=image/ GET /files?sort=-created_on&limit=5 GET /files/{uuid} ``` -------------------------------- ### Query Codex Items (List, Filter, Search, Sort, Paginate) Source: https://docs.decc0s.com/examples/introduction Demonstrates common operations for querying codex items, including listing all items, filtering by owner, searching by name, sorting results by date, and paginating through large datasets. ```http GET /items/codex?fields=id,name&limit=10 GET /items/codex/1 GET /items/codex?filter[owner][_eq]=0x... GET /items/codex?search=curator GET /items/codex?sort=-timestamp_created GET /items/codex?limit=10&offset=20&meta=* ``` -------------------------------- ### GET /items/codex - Nested Logical Operators Example Source: https://docs.decc0s.com/examples/advanced/complex-filters This example demonstrates combining `_and` and `_or` operators for complex filtering logic: find items where the name is not null AND (the ID is less than or equal to 10 OR the ID is greater than or equal to 100). ```APIDOC ## GET /items/codex - Nested Logical Operators ### Description Retrieves items where the name is not null AND (the ID is less than or equal to 10 OR the ID is greater than or equal to 100). ### Method GET ### Endpoint /items/codex ### Query Parameters - **filter** (string) - Required - JSON string representing nested filter conditions. Example: `{"_and":[{"name":{"_nnull":true}},{"_or":[{"id":{"_lte":10}},{"id":{"_gte":100}}]}]}` - **fields** (string) - Optional - Comma-separated list of fields to return. Example: `id,name` - **limit** (integer) - Optional - Maximum number of results to return. Example: `10` ### Request Example ```bash GET /items/codex?filter={"_and":[{"name":{"_nnull":true}},{"_or":[{"id":{"_lte":10}},{"id":{"_gte":100}}]}]}?fields=id,name&limit=10 ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the item. - **name** (string) - The name of the item. #### Response Example ```json { "id": 5, "name": "Nested Item" } ``` ``` -------------------------------- ### GET /items/codex - Pagination with Page Number Source: https://docs.decc0s.com/llms-full Alternatively, use the `page` parameter instead of `offset` for page-based pagination. ```APIDOC ## GET /items/codex ### Description Retrieves paginated results using limit and page number, with optional metadata for total counts. ### Method GET ### Endpoint /items/codex ### Query Parameters - **limit** (integer) - Optional - Maximum items to return. Defaults to 100. - **page** (integer) - Optional - Page number. Defaults to 1. - **meta** (string) - Optional - Include metadata. Use '*' for all metadata. Defaults to none. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name'. ``` -------------------------------- ### Files Examples Source: https://docs.decc0s.com/examples/introduction Access and filter stored files. Examples include listing files, filtering by type (images, documents), retrieving metadata, and querying recent uploads with sorting. ```APIDOC ## Files API Examples ### Description Examples demonstrating how to access and filter stored files, including listing all files, filtering by MIME type, retrieving metadata, and sorting recent uploads. ### Common File Queries | Use Case | Example | |---|---| | List files | `GET /files?fields=id,title,type&limit=10` | | Images only | `GET /files?filter[type][_starts_with]=image/` | | Recent uploads | `GET /files?sort=-created_on&limit=5` | | Get metadata | `GET /files/{uuid}` | ``` -------------------------------- ### Get File Metadata Source: https://docs.decc0s.com/llms-full Retrieve detailed metadata for a specific file by its UUID. Supports selecting specific fields. ```APIDOC ## GET /files/{id} ### Description Retrieve detailed metadata for a specific file by its UUID. Supports selecting specific fields. ### Method GET ### Endpoint /files/{id} ### Path Parameters - **id** (string) - Required - Unique file identifier (UUID). ### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to include in the response. ### Request Example ```bash GET /files/a1b2c3d4-e5f6-7890-1234-abcdef123456?fields=id,title,type,width,height,filesize ``` ### Response #### Success Response (200) - **data** (object) - Contains the file metadata. - **id** (string) - Unique file identifier (UUID). - **storage** (string) - File storage location. - **filename_disk** (string) - Filename on disk. - **filename_download** (string) - Original filename for download. - **title** (string) - File title. - **type** (string) - MIME type (e.g., `image/jpeg`). - **filesize** (integer) - Size in bytes. - **width** (integer) - Image width (images only). - **height** (integer) - Image height (images only). - **created_on** (string) - Upload timestamp. - **modified_on** (string) - Last modification timestamp. #### Response Example ```json { "data": { "id": "a1b2c3d4-e5f6-7890-1234-abcdef123456", "storage": "local", "filename_disk": "a1b2c3d4-e5f6-7890-1234-abcdef123456.jpg", "filename_download": "original-name.jpg", "title": "My Image", "type": "image/jpeg", "filesize": 1234567, "width": 1920, "height": 1080, "created_on": "2024-01-15T10:30:00Z", "modified_on": "2024-01-15T10:30:00Z" } } ``` ``` -------------------------------- ### GET /items/codex - Find Items Without Owner Source: https://docs.decc0s.com/llms-full This endpoint demonstrates how to find items where the owner field is null. ```APIDOC ## GET /items/codex ### Description Find items where the owner field is null. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **filter[owner][_null]** (boolean) - Optional - Filter items where owner is null. - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., id,name,owner). - **limit** (integer) - Optional - Maximum number of items to return. ### Request Example ```bash GET /items/codex?filter[owner][_null]=true&fields=id,name,owner&limit=10 ``` ### Response #### Success Response (200) - **items** (array) - Array of codex items. #### Response Example ```json { "items": [ { "id": 1, "name": "Item 1", "owner": null } ] } ``` ``` -------------------------------- ### Advanced Examples Source: https://docs.decc0s.com/examples/introduction Illustrates complex filters and logical operators. Learn to combine filters with AND/OR operators, exclude null values, and build sophisticated queries for precise data retrieval. ```APIDOC ## Advanced Filtering Examples ### Description Examples showcasing advanced filtering techniques using logical operators like AND/OR, handling null values, and constructing complex queries. ### Filter Operators The API uses Directus filter syntax. Common operators include: | Operator | Description | Example | |---|---|---| | `_eq` | Equals | `filter[name][_eq]=Korka` | | `_neq` | Not equals | `filter[status][_neq]=draft` | | `_contains` | Contains substring | `filter[name][_contains]=art` | | `_starts_with` | Starts with | `filter[type][_starts_with]=image/` | | `_gte` | Greater than or equal | `filter[id][_gte]=100` | | `_lte` | Less than or equal | `filter[id][_lte]=50` | | `_null` | Is null | `filter[ancestor][_null]=true` | | `_nnull` | Is not null | `filter[owner][_nnull]=true` | ### Syntax Notes Use **bracket notation** for simple filters: `filter[name][_eq]=value` Use **JSON syntax** for complex logic with `_and`/`_or`: `filter={"_and":[...]}` ``` -------------------------------- ### Retrieve Paginated Items (Bash) Source: https://docs.decc0s.com/examples/codex/pagination Fetches paginated results for items using GET request. Supports `limit`, `offset`, and `meta` parameters to control data retrieval and include metadata. Useful for building UI components that require total counts. ```bash GET /items/codex?limit=5&offset=0&meta=*&fields=id,name ``` -------------------------------- ### Get Item by ID Source: https://docs.decc0s.com/llms-full Retrieves a specific item from the codex by its ID, including specified fields and moltbot information. ```APIDOC ## GET /items/codex/{id} ### Description Retrieves a specific item from the codex by its ID, including specified fields and moltbot information. ### Method GET ### Endpoint /items/codex/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the item. #### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to include in the response. ### Request Example ```bash curl "${API_BASE_URL}/items/codex/1?fields=id,name,moltbot" ``` ### Response #### Success Response (200) - **data** (object) - Contains the item details. - **id** (integer) - The item's ID. - **name** (array) - The item's name(s). - **moltbot** (object) - Versioned information about the item. - **v0.1** (object) - Details for version 0.1. - **soul** (string) - Core identity and temperament information. - **identity** (string) - Descriptive identity details. #### Response Example ```json { "data": { "id": 1, "name": ["Parvata"], "moltbot": { "v0.1": { "soul": "# SOUL.md — Parvata\n\nYou are Parvata. Stay consistent with your identity.\n\n## Core Temperament\n fractured; surreal; paradoxical...", "identity": "# IDENTITY.md\n\nName: Parvata\nEmoji: 🌊\n\nSelf-identity: a male person\nResidence: Cairo, Cairo Governorate, Egypt..." } } } } ``` Multiple versions can coexist in the `moltbot` field. New versions are added without overwriting previous ones, allowing for character evolution tracking. ``` -------------------------------- ### Convert Image to Grayscale (Bash) Source: https://docs.decc0s.com/examples/assets/sharp Demonstrates converting an image to grayscale using the 'grayscale' operation within the 'transforms' parameter. This operation does not require any arguments. ```bash GET /assets/{id}?transforms=[["grayscale"]] ``` -------------------------------- ### GET /items/codex - Full-Text Search Source: https://docs.decc0s.com/query-guide Perform full-text search across multiple fields using the `search` parameter. ```APIDOC ## GET /items/codex ### Description Performs a full-text search across multiple fields of the items collection using the `search` query parameter. ### Method GET ### Endpoint /items/codex ### Query Parameters - **search** (string) - Optional - The search term to query across fields. ### Caution Search behavior is database-dependent. For complex searches, consider using specific field filters. ### Request Example ```bash GET /items/codex?search=curator ``` ``` -------------------------------- ### List Files with Basic Metadata (API) Source: https://docs.decc0s.com/llms-full Retrieve a list of files with basic metadata such as title, type, and filesize. This endpoint supports filtering and pagination. ```bash GET /files?fields=id,title,type,filesize&limit=10 ``` -------------------------------- ### GET /items/codex - Pagination with Metadata Source: https://docs.decc0s.com/query-guide Retrieve items with pagination and include metadata for UI elements like total counts. ```APIDOC ## GET /items/codex ### Description Retrieves a list of items with support for pagination and metadata. Including `meta=*` provides total counts for pagination UIs. ### Method GET ### Endpoint /items/codex ### Query Parameters - **limit** (integer) - Optional - The maximum number of items to return per page. - **offset** (integer) - Optional - The number of items to skip from the beginning of the collection. - **meta** (string) - Optional - Specifies the metadata to include in the response. Use `*` to include all available metadata, such as `total_count` and `filter_count`. ### Response #### Success Response (200) - **data** (array) - An array of item objects. - **meta** (object) - An object containing metadata about the query results. - **filter_count** (integer) - The number of items matching the current filter. - **total_count** (integer) - The total number of items in the collection. ### Response Example ```json { "data": [...], "meta": { "filter_count": 42, "total_count": 100 } } ``` ### Pagination Calculation - **Total Pages** = ceil(total_count / limit) - **Current Page** = floor(offset / limit) + 1 ``` -------------------------------- ### GET /items/codex - Search with Sorting Source: https://docs.decc0s.com/llms-full Sort search results by relevance or other fields. The `sort` parameter can be used in conjunction with the `search` parameter. ```APIDOC ## GET /items/codex ### Description Performs a full-text search and sorts the results. ### Method GET ### Endpoint /items/codex ### Query Parameters - **search** (string) - Required - The text to search for. - **sort** (string) - Optional - Comma-separated list of fields to sort by. Prefix with '-' for descending order. Example: '-timestamp_created'. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name,description,timestamp_created'. - **limit** (integer) - Optional - Maximum number of items to return. Defaults to 10. ``` -------------------------------- ### Query Parameters Overview Source: https://docs.decc0s.com/query-guide Overview of the available query parameters for filtering, sorting, searching, and pagination. ```APIDOC ## Query Parameters Overview | Parameter | Description | Example | |---|---|---| | `fields` | Select specific fields | `?fields=id,name` | | `filter` | Apply filter conditions | `?filter[name][_eq]=Korka` | | `sort` | Order results | `?sort=-created_on` | | `limit` | Maximum results | `?limit=25` | | `offset` | Skip results (pagination) | `?offset=50` | | `search` | Full-text search | `?search=curator` | | `meta` | Include metadata | `?meta=*` | ``` -------------------------------- ### GET /items/codex - Full-Text Search Source: https://docs.decc0s.com/llms-full Perform full-text search across all searchable fields in the codex collection using the `search` parameter. ```APIDOC ## GET /items/codex ### Description Performs a full-text search across all codex fields. ### Method GET ### Endpoint /items/codex ### Query Parameters - **search** (string) - Required - The text to search for across all fields. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name,description'. ``` -------------------------------- ### Chain Multiple Image Transformations (Bash) Source: https://docs.decc0s.com/examples/assets/sharp Shows how to chain multiple image transformation operations, such as rotate, grayscale, and blur, in the specified order. ```bash GET /assets/{id}?transforms=[["rotate",90],["grayscale"],["blur",2]] ``` -------------------------------- ### Transform Asset with Custom Parameters Source: https://docs.decc0s.com/files This snippet illustrates how to apply custom transformations to an asset, including setting width, height, fit mode, format, and quality. This provides fine-grained control over image manipulation directly through the API. ```bash curl "${API_BASE_URL}/assets/a1b2c3d4-e5f6-7890-1234-abcdef123456?width=800&height=600&fit=cover&format=webp&quality=80" ``` -------------------------------- ### GET /items/codex - Exclude Null Values Source: https://docs.decc0s.com/llms-full This endpoint demonstrates how to filter out items with null values in specific fields using the `_nnull` operator. ```APIDOC ## GET /items/codex ### Description Filter out items that have null values in specific fields using the `_nnull` (not null) operator. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **filter[ancestor][_nnull]** (boolean) - Optional - Filter items where ancestor is not null. - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., id,name,ancestor). ### Request Example ```bash GET /items/codex?filter[ancestor][_nnull]=true&fields=id,name,ancestor ``` ### Response #### Success Response (200) - **items** (array) - Array of codex items. #### Response Example ```json { "items": [ { "id": 1, "name": "Item 1", "ancestor": 10 } ] } ``` ``` -------------------------------- ### GET /items/codex - Search with Sorting Source: https://docs.decc0s.com/examples/codex/search Sort search results by relevance or other fields. This example searches for 'collection' and sorts results by creation timestamp in descending order. ```APIDOC ## GET /items/codex (Search with Sorting) ### Description Performs a full-text search and sorts the results based on a specified field. This is useful for ordering search results, for example, by creation date. ### Method GET ### Endpoint /items/codex ### Parameters #### Query Parameters - **search** (string) - Required - The text to search for across all searchable fields. - **sort** (string) - Optional - The field to sort by. Prefix with '-' for descending order (e.g., `-timestamp_created`). - **fields** (string) - Optional - A comma-separated list of fields to include in the response. - **limit** (integer) - Optional - The maximum number of results to return. ### Request Example ```bash GET /items/codex?search=collection&sort=-timestamp_created&fields=id,name,description,timestamp_created&limit=10 ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier of the item. - **name** (string) - Name of the item. - **description** (string) - Description of the item. - **timestamp_created** (string) - The creation timestamp of the item. #### Response Example ```json { "id": "some-id", "name": "Collection Item", "description": "An item from the collection.", "timestamp_created": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Directus Filter Syntax (Bracket vs JSON) Source: https://docs.decc0s.com/examples/introduction Explains the two primary syntaxes for applying filters in Directus: bracket notation for simple filters and JSON syntax for complex logical operations like AND/OR. ```http filter[name][_eq]=value filter={"_and":[...]} ``` -------------------------------- ### GET /items/codex - Combine Search with Filters Source: https://docs.decc0s.com/llms-full Combine full-text search with filters for more refined results. Filters target specific fields with precise operators. ```APIDOC ## GET /items/codex ### Description Performs a full-text search and applies filters to refine the results. ### Method GET ### Endpoint /items/codex ### Query Parameters - **search** (string) - Required - The text to search for. - **filter[id][_gte]** (integer) - Optional - Example filter to get items with an ID greater than or equal to 10. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. Defaults to 'id,name,description'. - **limit** (integer) - Optional - Maximum number of items to return. Defaults to 10. ``` -------------------------------- ### Get File Metadata by ID (API) Source: https://docs.decc0s.com/llms-full Retrieve detailed metadata for a specific file using its unique UUID. You can also specify which fields to return. ```bash GET /files/a1b2c3d4-e5f6-7890-1234-abcdef123456 ``` ```bash GET /files/a1b2c3d4-e5f6-7890-1234-abcdef123456?fields=id,title,type,width,height,filesize ``` -------------------------------- ### Paginate API Results Source: https://docs.decc0s.com/llms-full Demonstrates how to retrieve paginated results from the /items/codex endpoint. It shows basic pagination using limit and offset, and how to include metadata for UI elements like total counts. ```bash GET /items/codex?limit=10&offset=0 GET /items/codex?limit=10&offset=10 GET /items/codex?limit=10&offset=20 GET /items/codex?limit=10&offset=0&meta=* ``` -------------------------------- ### Transform Assets (Presets, Custom Size, Format, Rotate) Source: https://docs.decc0s.com/examples/introduction Illustrates various image transformation capabilities for assets. This includes using predefined presets for resizing, applying custom dimensions, converting formats, and rotating images. ```http GET /assets/{id}?key=s512 GET /assets/{id}?width=800&height=600 GET /assets/{id}?format=webp&quality=80 GET /assets/{id}?transforms=[["rotate",90]] ``` -------------------------------- ### GET /assets/{id} - Image Transformations Source: https://docs.decc0s.com/llms-full Apply custom transformations to images using query parameters for width, height, fit, format, and quality. ```APIDOC ## GET /assets/{id} ### Description Apply custom transformations to images using query parameters for width, height, fit, format, and quality. ### Method GET ### Endpoint /assets/{id} ### Path Parameters - **id** (string) - Required - The ID of the asset to transform. ### Query Parameters - **width** (number) - Optional - Target width in pixels. - **height** (number) - Optional - Target height in pixels. - **fit** (string) - Optional - How to fit the image. Values: `cover`, `contain`, `inside`, `outside`. Defaults to `cover`. - **format** (string) - Optional - Output image format. Values: `jpg`, `png`, `webp`, `avif`, `tiff`. - **quality** (number) - Optional - Compression quality (1-100). - **withoutEnlargement** (boolean) - Optional - If true, prevents upscaling small images. ### Request Example ```bash GET /assets/{id}?width=800&height=600&fit=cover&format=webp&quality=80 ``` ### Response #### Success Response (200) - **image** (binary) - The transformed image data. #### Response Example ```json { "example": "[Binary image data]" } ``` ``` -------------------------------- ### Combine Transforms with Other Parameters (Bash) Source: https://docs.decc0s.com/examples/assets/sharp Illustrates combining image transformations with standard API parameters like 'width' and 'format'. Transformations are specified within the 'transforms' array. ```bash GET /assets/{id}?width=800&format=webp&transforms=[["grayscale"],["sharpen"]] ```