Skip to main content

Search API

The Search API provides full-text search across all your content types — articles, pages, and custom collection items — from a single endpoint.

Endpoint

MethodEndpointDescription
GET/public/searchSearch across entities

Search

GET /public/search

Performs a full-text search and returns matching results from across content types.

Query Parameters

ParameterTypeRequiredDescription
keywordstringYesThe search term
scopestringNoLimit search scope: articles, pages, collections, or a specific collection UUID
limitintegerNoMaximum number of results to return

Scope Options

  • No scope — Searches across all entity types (articles, pages, and collection items).
  • articles — Search only in articles.
  • pages — Search only in pages.
  • collections — Search across all custom collection items.
  • Collection UUID — Search only within a specific custom collection's items.

Example Request: Global Search

curl -X GET "https://api.adaptocms.com/public/search?keyword=getting+started&limit=10" \
  -H "x-api-key: YOUR_API_KEY"

Example Request: Scoped to Articles

curl -X GET "https://api.adaptocms.com/public/search?keyword=tutorial&scope=articles&limit=5" \
  -H "x-api-key: YOUR_API_KEY"

Example Request: Scoped to a Specific Collection

curl -X GET "https://api.adaptocms.com/public/search?keyword=engineer&scope=coll-001&limit=5" \
  -H "x-api-key: YOUR_API_KEY"

Response Format

Returns an array of SearchResultModel objects:

[
  {
    "entity_type": "article",
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "title": "Getting Started with Adapto CMS",
    "slug": "getting-started-with-adapto-cms",
    "parent_id": null,
    "parent_name": null
  },
  {
    "entity_type": "page",
    "id": "page-001",
    "title": "Getting Started Guide",
    "slug": "getting-started-guide",
    "parent_id": null,
    "parent_name": null
  },
  {
    "entity_type": "collection_item",
    "id": "item-042",
    "title": "Quick Start Tutorial",
    "slug": "quick-start-tutorial",
    "parent_id": "coll-005",
    "parent_name": "Documentation"
  }
]

SearchResultModel Fields

FieldTypeDescription
entity_typestringType of entity: article, page, or collection_item
idstringUnique identifier of the matched entity
titlestringTitle of the matched entity
slugstringURL-friendly slug
parent_idstring | nullParent page ID or collection ID (for collection items)
parent_namestring | nullParent page title or collection name

Use Case: Site-Wide Search

async function siteSearch(query) {
  const results = await fetch(
    `${BASE_URL}/public/search?keyword=${encodeURIComponent(query)}&limit=20`,
    { headers: { 'x-api-key': API_KEY } }
  ).then(r => r.json());

  // Group results by type
  const grouped = {
    articles: results.filter(r => r.entity_type === 'article'),
    pages: results.filter(r => r.entity_type === 'page'),
    collections: results.filter(r => r.entity_type === 'collection_item')
  };

  return grouped;
}

// Build search result links
function getResultUrl(result) {
  switch (result.entity_type) {
    case 'article': return `/blog/${result.slug}`;
    case 'page': return `/${result.slug}`;
    case 'collection_item': return `/collections/${result.parent_id}/${result.slug}`;
  }
}