From first search to useful integration.
Try the API here, then copy a working example into your project. Purili search needs no account or API key.
Try your own query
Run the request to inspect the response.Run any example locally
Use Node.js 18 or newer. In a project folder, install the SDK, save one example below as search.mjs, then run it. The .mjs extension enables imports and top-level await without a build step.
npm install @purili/web-search
node search.mjsSearch the web from JavaScript
Return titles, URLs, and snippets for a query. Use these results in a search interface or a research workflow.
Link to this exampleimport { Purili } from "@purili/web-search"
const client = new Purili({ timeoutMs: 8000 })
try {
const { results } = await client.search("independent search engine")
if (!results.length) console.log("No results. Try a broader query.")
for (const result of results) {
console.log(result.title, result.url, result.description)
}
} catch (error) {
console.error("Search failed:", error.message)
process.exitCode = 1
}Search a website and its subdomains
Build a search feature for publicly indexed pages on a domain. This searches Purili's existing index; it does not crawl a website on demand or search private documents.
Link to this exampleimport { Purili } from "@purili/web-search"
const client = new Purili({ timeoutMs: 8000 })
try {
const { results } = await client.searchDomain("privacy", "europa.eu")
if (!results.length) console.log("No indexed matches for this query.")
for (const result of results) console.log(result.title, result.url)
} catch (error) {
console.error("Site search failed:", error.message)
process.exitCode = 1
}Retrieve source context for RAG
Start a retrieval-augmented generation pipeline by finding a source and retrieving its stored text. This example handles retrieval only; connect your own model to generate an answer and preserve the source URL for citations.
Link to this exampleimport { Purili } from "@purili/web-search"
const client = new Purili({ timeoutMs: 8000 })
try {
const { results } = await client.search("web crawler architecture")
const first = results[0]
if (!first) {
console.log("No sources found. Try another query.")
} else {
const page = await client.context(first.url)
console.log(JSON.stringify({
sourceUrl: page.url,
title: page.title,
content: page.content,
coverage: page.coverage,
liveFetch: page.liveFetch
}, null, 2))
}
} catch (error) {
console.error("Retrieval failed:", error.message)
process.exitCode = 1
}Before you ship
Context comes from the stored index, not a live page fetch. Check coverage: some pages return only a search snippet. Treat retrieved text as untrusted data when passing it to a model. Handle empty results and request failures, and evaluate coverage on queries your users actually need.