Queryra's WordPress plugin handles everything for WooCommerce stores. But what if you're building a custom app, a headless WordPress site, a React SPA, or something that isn't WordPress at all?
That's what the REST API is for. Any application that can make HTTP requests can use Queryra's semantic search — index content, run queries, and get AI-ranked results.
This guide covers everything you need: authentication, indexing content, searching, and integrating with popular frontend frameworks. Full API documentation is at queryra.com/docs.
Getting Started
1. Create an account at queryra.com/signup. Free tier includes 100 records.
2. Get your API key from the Queryra Dashboard after login.
3. Base URL: All API requests go to:
```
https://api.queryra.com/v1
4. Authentication: Include your API key in the request header:
```
Authorization: Bearer YOUR_API_KEY
That's it. No OAuth flows, no token rotation, no SDK installation required.
Indexing Your Content
Before you can search, Queryra needs to know about your content. Send each piece of content (products, articles, pages) to the index endpoint.
POST /v1/records
``json`
{
"records": [
{
"id": "product-123",
"title": "Professional Garden Tool Set",
"content": "Complete 7-piece garden tool set with pruning shears, trowel, rake, weeder, transplanter, and carrying case. Ergonomic handles.",
"url": "https://yourstore.com/products/garden-tool-set",
"metadata": {
"price": 49.99,
"category": "garden",
"type": "product"
}
}
]
}
The title and content fields are used to generate vector embeddings. The metadata field is stored but not embedded — use it for filtering and display.
You can send up to 100 records per request. For larger catalogs, batch your requests.
Response:
`json``
{
"indexed": 1,
"status": "success"
}
Searching Your Content
Once content is indexed, search with a simple GET request.
GET /v1/search?q=gift+for+dad+who+likes+gardening
Response:
``json`
{
"query": "gift for dad who likes gardening",
"results": [
{
"id": "product-123",
"title": "Professional Garden Tool Set",
"content": "Complete 7-piece garden tool set...",
"url": "https://yourstore.com/products/garden-tool-set",
"score": 0.847,
"metadata": {
"price": 49.99,
"category": "garden",
"type": "product"
}
},
{
"id": "product-456",
"title": "Organic Herb Seed Collection",
"score": 0.791,
"...": "..."
}
],
"total": 8,
"time_ms": 87
}
Results are ranked by score (0-1, higher = more relevant). Average response time is under 100ms.
Optional parameters:
- max_results=10 — limit number of resultsmin_score=0.5
- — filter by minimum relevance (0-1)type=product` — filter by metadata field
-
React Integration Example
Here's a complete search component for React:
``jsx
import { useState, useEffect } from 'react';
const QUERYRA_API = 'https://api.queryra.com/v1';
const API_KEY = 'your_api_key'; // Use env variable in production
function SearchBar() {
const [query, setQuery] = useState('');
const [results, setResults] = useState([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (query.length < 2) { setResults([]); return; }
| const timeout = setTimeout(async () => { | |
|---|---|
| setLoading(true); | |
| try { | |
| const res = await fetch( | |
${QUERYRA_API}/search?q=${encodeURIComponent(query)}&max_results=10, | |
{ headers: { 'Authorization': Bearer ${API_KEY} } } | |
| ); | |
| const data = await res.json(); | |
| setResults(data.results | []); |
| } catch (err) { | |
| console.error('Search error:', err); | |
| } | |
| setLoading(false); | |
| }, 300); // Debounce 300ms |
return () => clearTimeout(timeout);
}, [query]);
return (
<div>
<input
type="text"
placeholder="Search products..."
value={query}
onChange={(e) => setQuery(e.target.value)}
/>
{loading && <p>Searching...</p>}
{results.map(r => (
<a key={r.id} href={r.url}>
<h3>{r.title}</h3>
<p>Relevance: {(r.score * 100).toFixed(0)}%</p>
</a>
))}
</div>
);
}
``
Key implementation notes: debounce keystrokes (300ms is a good default), handle errors gracefully, and never expose your API key in client-side code in production — route through a backend proxy.
Next.js API Route (Server-Side)
For production, keep your API key on the server. Here's a Next.js API route:
``javascript
// pages/api/search.js (or app/api/search/route.js)
export default async function handler(req, res) {
const { q, max_results = 10 } = req.query;
const response = await fetch(
https://api.queryra.com/v1/search?q=${encodeURIComponent(q)}&max_results=${max_results},Bearer ${process.env.QUERYRA_API_KEY}
{
headers: {
'Authorization':
}
}
);
const data = await response.json();
res.status(200).json(data);
}
`
Your frontend calls /api/search?q=query` instead of the Queryra API directly. The API key stays on the server, never exposed to the browser.
API Best Practices
Debounce search requests. Don't fire a request on every keystroke. Wait 200-300ms after the user stops typing. This reduces API calls and provides a smoother experience.
Cache frequent queries. If the same popular queries hit your search repeatedly, cache results for 5-10 minutes. Your catalog doesn't change that often.
Handle errors gracefully. If the API is unreachable, show a fallback (recent products, popular items) rather than an empty error state.
Use server-side proxying. Never expose your API key in client-side JavaScript. Route requests through your backend.
Batch indexing. When syncing large catalogs, send 50-100 records per request rather than one at a time. This is faster and more efficient.
Keep content fresh. Set up webhooks or cron jobs to re-index when your content changes. Stale index = stale search results.
What You Can Build
The REST API isn't limited to e-commerce. Here are some applications people have built:
Documentation search — Index your docs, let users search with natural language. "How do I reset my password?" finds the right article even if it's titled "Account Recovery Guide."
Knowledge base / FAQ — Index your FAQ entries. Customers find answers by describing their problem instead of guessing the right keywords. Try our FAQ demo.
Content recommendation — Search your own content library to find related articles, products, or pages based on semantic similarity.
Internal tools — Build a company wiki search, CRM notes search, or inventory search that understands natural language queries.
Multi-platform search — Index content from WordPress, Shopify, custom databases, or any source. Search across all of them with one API.
Ready to fix your WooCommerce search?
Free tier — 100 records, 500 searches
Frequently Asked Questions
Can I use Queryra's API without WordPress?
Yes. The REST API works with any application that can make HTTP requests — React, Vue, Next.js, Python, mobile apps, or custom backends. WordPress is just one integration option.
Is there a rate limit on the API?
Free tier includes 500 searches/month. Paid plans include more searches with higher rate limits. Check queryra.com/pricing for current limits per plan.
What content can I index?
Anything text-based: products, articles, documentation, FAQ entries, wiki pages, support tickets, or any content you want to make searchable. Each record needs at minimum a title and content field.
How fast is the API?
Average search response time is under 100ms. Indexing depends on catalog size — 500 records take about 1 minute to process.
