Search History API

Requires Subscription

The Search History API uses the /api/v1/search_history endpoint, allowing you to retrieve, filter, and paginate your account's search history. This API supports keyset pagination to efficiently handle large datasets.

This API is free of charge to use and provides access to your search history from the past 60 days only. Older search records are not accessible via this endpoint.

API Parameters

Search Parameters

  • Name
    limit
    Required
    Optional
    Description

    The maximum number of results to return. Defaults to 20. Maximum is 100.

  • Name
    engine
    Required
    Optional
    Description

    Filter the search history by engine (e.g., google, bing).

  • Name
    time_period_min
    Required
    Optional
    Description

    The start of the time period to filter by (e.g., 2024-10-01).

  • Name
    time_period_max
    Required
    Optional
    Description

    The end of the time period to filter by (e.g., 2024-10-15).

  • Name
    next_page_token
    Required
    Optional
    Description

    The token used to retrieve the next page of results, provided in the previous response.

  • Name
    api_key
    Required
    Required
    Description

    The api_key authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search_history?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).

API Examples

Search History

This example retrieves the first 20 searches from your search history. Use the next_page_token to request the next page of results.

Response parameters:

  • id - The unique identifier of the search (e.g., search_abc123).
  • engine - The search engine used for this query (e.g., google).
  • params - The parameters used in the original search.
  • status - The final status of the search (e.g., Success, Error).
  • created_at - The timestamp when the search was created.
  • request_time_taken - The time taken to send the request, in seconds.
  • parsing_time_taken - The time taken to parse the response, in seconds.
  • total_time_taken - The total time taken for the search, including request and parsing.
  • html_url - A public HTML link to the search result, if search was successful.
  • json_url - A public JSON link to the search result, if search was successful.

GET
https://www.searchapi.io/api/v1/search_history
Request
import requests

url = "https://www.searchapi.io/api/v1/search_history"
params = {}

response = requests.get(url, params=params)
print(response.text)
Response
{
  "searches": [
    {
      "id": "search_J2OR1XvYom9LF45noGra4w0N",
      "engine": "google",
      "params": { "q": "ChatGPT" },
      "status": "Success",
      "created_at": "2024-10-17T10:00:00Z",
      "request_time_taken": 0.5,
      "parsing_time_taken": 0.1,
      "total_time_taken": 0.6,
      "html_url": "https://www.searchapi.io/api/v1/public_search/search_J2OR1XvYom9LF45noGra4w0N.html",
      "json_url": "https://www.searchapi.io/api/v1/public_search/search_J2OR1XvYom9LF45noGra4w0N.json"
    }
  ],
  "pagination": {
    "next_page_token": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMC0xNyIsImlkIjoic2VhcmNoX0oyT1IxWHZZb205TEY0NW5vR3JhNHcwTiJ9"
  }
}