Search API Deep Dive
Search API Deep Dive
The Search API is the core of SearchJet, providing full-text search capabilities powered by Meilisearch. Use this endpoint to search across all indexed content on your site.
Endpoint
GET /v1/search
Authentication
All search requests require a Bearer token in the Authorization header. Use your search key (sj_srch_) or private key (sj_prv_).
Authorization: Bearer sj_srch_xxxxxxxxxxxxxxxx
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q |
string | Yes | The search query string |
site_id |
integer | No | Site ID (usually inferred from the API key) |
limit |
integer | No | Number of results per page (default: 20, max: 100) |
offset |
integer | No | Number of results to skip (for pagination) |
page |
integer | No | Page number (alternative to offset) |
filters |
string | No | Filter expression (Meilisearch syntax) |
sort |
string | No | Sort order (e.g., date:desc, title:asc) |
facets |
string | No | Facets to return (comma-separated field names) |
Example Request
curl -X GET "https://app.searchjetengine.com/v1/search?q=installation+guide&limit=10" \
-H "Authorization: Bearer sj_srch_xxxxxxxxxxxxxxxx"
const response = await fetch(
'https://app.searchjetengine.com/v1/search?q=installation+guide&limit=10',
{
headers: {
'Authorization': 'Bearer sj_srch_xxxxxxxxxxxxxxxx'
}
}
);
const data = await response.json();
console.log(data.results.hits);
import httpx
response = httpx.get(
"https://app.searchjetengine.com/v1/search",
params={"q": "installation guide", "limit": 10},
headers={"Authorization": "Bearer sj_srch_xxxxxxxxxxxxxxxx"}
)
data = response.json()
print(data["results"]["hits"])
Response Format
{
"results": {
"hits": [
{
"id": "doc-123",
"title": "Installation Guide",
"content": "Full text content of the document...",
"url": "/docs/installation",
"excerpt": "A step-by-step guide to installing SearchJet...",
"author": "SearchJet Team",
"date": "2024-01-15T10:00:00Z"
}
],
"estimatedTotalHits": 42,
"processingTimeMs": 5,
"query": "installation guide"
},
"remaining_quota": {
"daily_limit": 10000,
"used_today": 150,
"remaining": 9850
}
}
Filter Syntax
SearchJet uses Meilisearch-compatible filter syntax:
| Filter | Description |
|---|---|
status=published |
Exact match |
author="John Doe" |
Exact match with quotes |
date>2024-01-01 |
Greater than |
date<2024-12-31 |
Less than |
category=tech AND status=published |
Multiple filters |
Pagination
Offset-based:
/v1/search?q=guide&limit=10&offset=20
Page-based:
/v1/search?q=guide&limit=10&page=3
Sorting
Sort results by any indexed field:
/v1/search?q=guide&sort=date:desc
/v1/search?q=guide&sort=title:asc
Error Responses
| Status | Description |
|---|---|
400 |
Missing or invalid query parameter |
401 |
Invalid or missing API key |
403 |
Key does not have search permissions |
429 |
Rate limit exceeded |
500 |
Internal server error |
Best Practices
- Use specific queries - More specific queries return more relevant results
- Implement pagination - Use
limitandoffsetfor large result sets - Cache responses - Cache search results for repeated queries
- Handle errors gracefully - Always check for error responses
- Monitor usage - Track your API usage via the
/v1/client-infoendpoint