Skip to main content
Mintlify
current

Search documentation

Type to search this documentation.

On this pageOverview

Get search queries

Returns paginated documentation search terms for the date range, ordered by hit count descending. Each row includes click-through rate, the most-clicked result path for that query (if any), and the last time the term was searched. totalSearches is the total number of search query events in the same date range (sum of all hits, not distinct queries).

Authenticate with an admin API key.

Use this endpoint to export documentation search analytics. Results are ordered by hit count descending, showing which terms your users search for most.

Paginate through results using the nextCursor parameter returned in the response. Continue fetching while nextCursor is not null.

Filter search data by date range using dateFrom and dateTo parameters.

This endpoint allows 100 requests per organization per hour. All analytics endpoints share this limit.

Related topics

GET/v1/analytics/{projectId}/searches

Get search queries

5 parameters
  • projectIdstringpathrequired
  • dateFromstringquery
  • dateTostringquery
  • limitnumberquery
  • cursorstringquery
cURL
curl --request GET \
  --url https://api.mintlify.com/v1/analytics/{projectId}/searches \
  --header 'Authorization: Bearer <token>'
Python
import requests

url = "https://api.mintlify.com/v1/analytics/{projectId}/searches"

headers = {
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers)

print(response.text)
JavaScript
const options = {method: "GET", headers: {"Authorization": "Bearer <token>"}};

fetch("https://api.mintlify.com/v1/analytics/{projectId}/searches", options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.mintlify.com/v1/analytics/{projectId}/searches",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mintlify.com/v1/analytics/{projectId}/searches"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
Java
HttpResponse<String> response = Unirest.get("https://api.mintlify.com/v1/analytics/{projectId}/searches")
  .header("Authorization", "Bearer <token>")
  .asString();
Ruby
require 'uri'
require 'net/http'

url = URI("https://api.mintlify.com/v1/analytics/{projectId}/searches")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
200
{
  "searches": [
    {
      "searchQuery": "<string>",
      "hits": 123,
      "ctr": 123,
      "topClickedPage": "<string>",
      "lastSearchedAt": "<string>"
    }
  ],
  "totalSearches": 123,
  "nextCursor": "<string>"
}
400
{
  "error": "<string>",
  "details": [
    {
      "message": "<string>"
    }
  ]
}
500
{
  "error": "<string>",
  "details": [
    {
      "message": "<string>"
    }
  ]
}
Authorizationstringrequired

The Authorization header expects a Bearer token. Use an admin API key. This is a server-side secret key. Generate one on the API keys page in your dashboard.

projectIdstringrequired
dateFrom?string

Example: 2024-01-01

Typestring
dateTo?string

Example: 2024-01-01

Typestring
limit?number

Required range: 1 <= x <= 100

Typenumber
Default50
cursor?string

200 — Search term aggregates with pagination

searchesobject[]required

Search terms ordered by hit count descending.

Typeobject[]
Show child attributes
searchQuerystringrequired

The search term entered by users.

Typestring
hitsnumberrequired

Number of times this term was searched.

Typenumber
ctrnumberrequired

Percentage of searches for this term that resulted in a click on a specific search result (clicks ÷ hits × 100). A click includes selecting a result with the pointer or pressing Enter when a result is highlighted. Submitting a query by itself does not count as a click. Clicking the AI assistant in the search bar, or pressing Enter to use it, counts as a search with no click and is not tracked separately in this field.

Typenumber
topClickedPagestring | nullrequired

The most-clicked result path for this query, if any.

Typestring | null
lastSearchedAtstringrequired

Timestamp of the last time this term was searched.

Typestring
totalSearchesintegerrequired

Total count of search events in the requested date range (sum of all hits, not distinct queries).

Required range: 0 <= x

Typeinteger
nextCursorstring | nullrequired

Opaque pagination cursor for the next page. Null if no more results.

Typestring | null
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu