Exa SDK for Node.js and the browser
npm install exa-js
The official JavaScript SDK for Exa, the web search API built for AI.
``bash`
npm install exa-js
`ts
import Exa from "exa-js";
const exa = new Exa(process.env.EXA_API_KEY);
// Search the web
const result = await exa.search(
"blog post about artificial intelligence",
{
type: "auto",
contents: {
text: true
}
}
);
// Find similar pages
const result = await exa.findSimilar(
"https://paulgraham.com/greatwork.html",
{
contents: {
text: true
}
}
);
// Get answers with citations
const { answer } = await exa.answer("What is the capital of France?");
`
Find webpages using natural language queries.
`ts`
const result = await exa.search("interesting articles about space", {
numResults: 10,
includeDomains: ["nasa.gov", "space.com"],
startPublishedDate: "2024-01-01",
contents: {
text: true
}
});
Get clean text, highlights, or summaries from any URL.
`ts`
const { results } = await exa.getContents(["https://openai.com/research"], {
text: true,
highlights: true,
summary: true,
});
Discover pages similar to a given URL.
`ts`
const result = await exa.findSimilar(
"https://paulgraham.com/greatwork.html",
{
numResults: 10,
excludeSourceDomain: true,
contents: {
text: true
}
}
);
`ts`
const response = await exa.answer("What caused the 2008 financial crisis?");
console.log(response.answer);
`ts`
for await (const chunk of exa.streamAnswer("Explain quantum computing")) {
if (chunk.content) {
process.stdout.write(chunk.content);
}
}
Run autonomous research tasks that return structured data.
`ts
const { researchId } = await exa.research.create({
instructions: "Find the top 5 AI startups founded in 2024",
outputSchema: {
type: "object",
properties: {
startups: { type: "array", items: { type: "string" } },
},
},
});
const result = await exa.research.pollUntilFinished(researchId);
`
Full TypeScript support with types for all methods.
`ts``
import Exa from "exa-js";
import type { SearchResponse, RegularSearchOptions } from "exa-js";
- Documentation
- API Reference
- Examples
Pull requests welcome! For major changes, open an issue first.