Skip to main content

Search Results API

Use the AddSearch REST API to retrieve search results from your search index. This endpoint returns results in JSON format with flexible filtering, sorting, and pagination options.

Note: When you implement search using this API, you must report user clicks to the Report User Event endpoint. Click data enables detailed analytics reports in the Analytics Dashboard and allows AddSearch to improve result relevancy through progressive ranking.

HTTP Request

GET /v1/search/{index_public_key}

Replace {index_public_key} with your site's public API key (SITEKEY). Do not use your secret API key here.


Required Query Parameter

ParameterDescriptionType
termSearch term (keyword). Use * to retrieve all results.string

Optional Query Parameters

ParameterDescriptionTypeNotes
limitNumber of results per pageinteger1–300, default 10
pagePage number for paginationintegerDefault is 1
jsonpWraps JSON response in a JavaScript function call (JSONP)stringUsed for cross-domain requests. When omitted, response is pure JSON.
langLimit results to a specific languagestringUse two-letter codes (e.g., "en", "de", "es"). See Language Documentation. Default returns all languages.
categoriesFilter results by domain, URL path, or file typestringSee Category Filters. Example below. Default returns all categories.
sortSort results by "relevance", "date", or a custom field (e.g., custom_fields.average_rating)stringDefault is "relevance"
orderSort order: ascending (asc) or descending (desc)stringApplies when sorting by date or custom fields. Default is "desc"
fuzzyEnable fuzzy matching to find approximate matchesstring"false" (disabled), "true" (enabled), or "auto" (automatic). Recommended default is "auto". Default is "false" (verify this).
postfixWildcardAppend wildcard to the end of search term (useful for search-as-you-type)booleanDefault true. Set to false for stricter exact matches and fewer highlights.
dateFromReturn results newer than this date (format: yyyy-mm-dd)stringDefault includes all dates
dateToReturn results older than this date (format: yyyy-mm-dd)stringDefault includes all dates
customFieldFilter results by custom field with key=value pairs, URL-encodedstringMultiple values for the same key perform an OR match; multiple keys perform AND. See Using Custom Fields and example below.
resultTypeReturn all results or only organic (exclude pinned/promotions)string"all" (default) or "organic"
userTokenToken for personalized search resultsstringOptional
facetReturn aggregation counts for specified fieldsstringPass one or more fields for faceting. See example below. Default: no facets returned.
numFacetsMaximum number of facet aggregations per fieldintegerMax 1000, default 10
rangeFacetsGroup numerical custom fields into specified rangesobjectJSON object describing ranges. See example below. Default: no range facets.
collectAnalyticsInclude this search event in Analytics Dashboard statisticsbooleanDefault true.
analyticsTagTag string for filtering analytics reportsstringMax 50 characters. See Analytics Tags for details.
filterComplex filter object using custom_fields, supporting AND, OR, NOT, and range filtersobjectSupports nested logic. See examples below.
defaultOperatorLogical operator for multi-word fuzzy queries: "or" or "and"stringApplies when fuzzy=auto. "or" broadens matches (partial terms), "and" restricts to mistypes only.

Examples

Categories Parameter

For the URL www.example.com/news/article.pdf, the categories are:

  • 0=www.example.com
  • 1=news
  • doctype_pdf

Use these to filter results:

ParameterReturns results from
&categories=0xwww.example.comThe entire domain www.example.com
&categories=1xnewsThe /news/ path
&categories=doctype_pdfDocuments with PDF filetype

Custom Field Parameter

To return results where city is London AND genre is rock OR pop:

&customField=city%3DLondon&customField=genre%3Drock&customField=genre%3Dpop

(Values must be URL-encoded; = becomes %3D.)

Facet Parameter

To get aggregations of search results by custom fields genre and artist:

&facet=custom_fields.genre&facet=custom_fields.artist

To get aggregations by blog category:

&facet=categorys&categories=1xblog

Range Facets Parameter

Group custom_fields.price into ranges:

[
{
"field": "custom_fields.price",
"ranges": [
{ "to": 10 },
{ "from": 10, "to": 20 },
{ "from": 20 }
]
}
]

URL-encoded as:

rangeFacets=%5B%7B%22field%22%3A%20%22custom_fields.price%22%2C%22ranges%22%3A%20%5B%7B%22to%22%3A10%7D%2C%7B%22from%22%3A10%2C%22to%22%3A20%7D%2C%7B%22from%22%3A20%7D%5D%7D%5D

Filter Parameter

Return results with price between 10000 and 20000:

{
"range": {
"custom_fields.price": {
"gt": "10000",
"lt": "20000"
}
}
}

URL-encoded:

filter%3D%7B%22range%22%3A%7B%22custom_fields.price%22%3A%7B%22gt%22%3A%2210000%22%2C%22lt%22%3A%2220000%22%7D%7D%7D

Return results where brand is apple, color is not white, and price is between 200 and 500:

{
"and": [
{ "custom_fields.brand": "apple" },
{ "not": { "custom_fields.color": "white" } },
{ "range": { "custom_fields.price": { "gt": 200, "lt": 500 } } }
]
}

URL-encoded:

filter%3D%7B%22and%22%3A%5B%7B%22custom_fields.brand%22%3A%22apple%22%7D%2C%7B%22not%22%3A%7B%22custom_fields.color%22%3A%22white%22%7D%7D%2C%7B%22range%22%3A%7B%22custom_fields.price%22%3A%7B%22gt%22%3A200%2C%22lt%22%3A500%7D%7D%7D%5D%7D

Return results from example.com domain and /blog/ path:

{
"and": [
{ "category": "0xexample.com" },
{ "category": "1xblog" }
]
}

URL-encoded:

%7B%22and%22%3A%5B%7B%22category%22%3A%220xexample.com%22%7D%2C%7B%22category%22%3A%221xblog%22%7D%5D%7D

Return results where custom_fields.manufacturer matches any case variation of "nokia":

{
"and": [
{
"or": [
{ "custom_fields.manufacturer": "nokia" },
{ "custom_fields.manufacturer": "Nokia" },
{ "custom_fields.manufacturer": "NOKIA" }
]
}
]
}

URL-encoded:

%7B%22and%22%3A%5B%7B%22or%22%3A%5B%7B%22custom_fields.manufacturer%22%3A%22nokia%22%7D%2C%7B%22custom_fields.manufacturer%22%3A%22Nokia%22%7D%2C%7B%22custom_fields.manufacturer%22%3A%22NOKIA%22%7D%5D%7D%5D%7D

Sample Request

GET https://api.addsearch.com/v1/search/cfa10522e4ae6987c390ab72e9393908?term=rest+api

Sample Response

{
"page": 1,
"total_hits": 1,
"processing_time_ms": 21,
"hits": [
{
"id": "54f5b92d4e4766f4bc0ce2b05f80f58d",
"thumbnail_external_src": "https://www.example.com/thumbnail-image.jpg",
"url": "https://www.addsearch.com/developers/api/",
"title": "AddSearch REST API",
"meta_description": "Documentation of our REST API",
"meta_categories": ["features", "api"],
"custom_fields": {
"location": "London",
"genre": ["Rock", "Pop"]
},
"highlight": "AddSearch’s REST API provides programmatic access to your search index",
"ts": "2015-01-22T11:56:10",
"categories": [
"0xwww.addsearch.com",
"1xdevelopers",
"2xapi"
],
"document_type": "html",
"images": {
"main": "https://d20vwa69zln1wj.cloudfront.net/1bed1ffde465fddba...",
"main_b64": "/9j/4AAQSkZJRgABAQIAHAAcAAD/2wBDACgcHiMeGSgjISMtKygwPG...",
"capture": "https://d20vwa69zln1wj.cloudfront.net/1bed1ffde465fddba..."
},
"score": 0.790107
}
],
"facets": null,
"rangeFacets": null
}

Returned Fields Description

  • page: Requested page number
  • total_hits: Total number of matching documents
  • processing_time_ms: Time in milliseconds to process the request
  • hits: Array of matched documents

Each document in hits contains:

FieldDescriptionType
idDocument identifierstring
thumbnail_external_srcURL of thumbnail imagestring (URL)
urlDocument URLstring
titleDocument titlestring
meta_descriptionDocument meta description (nullable)string or null
meta_categoriesDocument meta categories (nullable)array of strings or null
custom_fieldsCustom metadata fieldsobject with string or array values
highlightSearch term matching text snippetstring
tsPublish date/time (ISO 8601 format)string
categoriesAutomatic categories like domain or filetypearray of strings
document_typeDocument type: html, pdf, docx, pptx, etc.string
imagesImages object with thumbnail and capturesobject
images.mainThumbnail image URL (nullable)string or null
images.main_b64Base64 encoded low-res thumbnail (nullable)string or null
images.captureURL for screen capture image (nullable)string or null
scoreRelevance score for the documentnumber
facetsAggregation data for facets (nullable)object or null
rangeFacetsNumerical range aggregations (nullable)object or null

Query Limits

The term parameter supports:

  • Maximum length: 300 characters
  • Maximum number of words: 20


For detailed information on filtering, faceting, and custom fields, refer to the linked documentation sections within this article.