You're reading "Content Management API"

Search result

DatoCMS Site Search is a way to deliver tailored search results to your site visitors. This is the endpoint you can use to query for results.

The Search result object

A Search result object is returned as part of the response body of each successful Index API call. The following table contains the list of all its fields along with their type, description and example values.

Object fields:
body_excerptstring

First lines of body

This attribute is required
highlightobject
scorenumber

Score

This attribute is required
titlestring

Page title

This attribute is required
urlstring

URL

This attribute is required

Search for results

To search for results, send a GET request to the /search-results endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/search-results HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": [ { "type": "search_result", "id": "312", "attributes": { "title": "My Page", "body_excerpt": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod", "url": "Smith", "score": 11.3, "highlight": { "title": [ "Foo <em>bar</em> qux" ], "body": [ "Foo <em>bar</em> qux" ] } } } ], "meta": { "total_count": 20 } }