Search

1GET https://api.markprompt.com/search

Retrieves a list of searchs result that match a query.

Request body

Key Type Description Default
query string

The search query string.

projectKey string

Optional, if not using a bearer token. The project key associated to your project. If shared publicly, use the production key from a whitelisted domain. If not, for instance on localhost, use the development key.

limit number

The maximum number of results to return.

10
includeSectionContent boolean

Whether to return the full content of matching sections, in addition to snippets.

false

Example request

1curl "https://api.markprompt.com/search?query=react&limit=4" \
2  -X GET \
3  -H "Authorization: Bearer <TOKEN>"
4  -H "Content-type: application/json" \
5  -H "Accept: application/json"

Response

The response is of the form:

1{
2  "data": [
3    { "matchType": "title", "file": { "...": "..." } },
4    {
5      "matchType": "leadHeading",
6      "file": { "...": "..." },
7      "meta": { "...": "..." }
8    },
9    { "matchType": "content", "file": { "...": "..." } }
10  ]
11}

A search result is similar to a reference object used in completions references, with an additional field describing the match type:

1type SearchResult = {
2  matchType: 'title' | 'leadHeading' | 'content';
3  file: {
4    title?: string;
5    path: string;
6    meta?: any;
7    source: Source;
8  };
9  meta?: {
10    leadHeading?: {
11      id?: string;
12      depth?: number;
13      value?: string;
14      slug?: string;
15    };
16  };
17};

Search results are ranked depending on the match type: higher weights are put on title matches, then section lead headings, and finally on content.