Exa API bindings: neural web search with page contents (https://docs.exa.ai), pages similar to a URL, and clean page text.
Setup: context variable exa.api.key, or a per-call api-key in
the trailing opts Map of any API-calling function (see
::exa::api). Sent as x-api-key.
Quick start
out ::exa/search("startups building sql runtimes", {
numResults: 5,
contents: {text: {maxCharacters: 2000}}
})
map(out.results, (r) { `${r.title} - ${r.url}` })
similar ::exa/find-similar("https://hot.dev", {numResults: 5})
pages ::exa/get-contents(["https://hot.dev"])
Options use Exa's own names, and functions return Exa's own response.
A failed call is an Err carrying ::exa::http/HttpError.
Context Vars
exa.api.key
Values
BASE_URL
BASE_URL: Str "https://api.exa.ai"
Functions
build-request
fn (path: Str, body: Map, api-key: Str): ::hot::http/HttpRequest
The outgoing HttpRequest for a key. Pure; exposed for testing.
Example
r ::exa/build-request("/search", {query: "hot language", category: null}, "test-key")
r.url // "https://api.exa.ai/search"
r.body // "{\"query\":\"hot language\"}"
find-similar
fn (url: Str): Map
fn (url: Str, options: Map): Map
fn (url: Str, options: Map, opts: Map): Map
POST /findSimilar - Pages similar to a URL. options: numResults,
includeDomains/excludeDomains, excludeSourceDomain,
startPublishedDate, contents.
Example
out ::exa/find-similar("https://hot.dev", {numResults: 5, excludeSourceDomain: true})
map(out.results, (r) { r.url })
// With another tenant's key
key ::hot::ctx/get("tenant-b.exa.api.key")
::exa/find-similar("https://hot.dev", {numResults: 5}, {api-key: key})
exa.api.key
get-contents
fn (urls: Vec): Map
fn (urls: Vec, options: Map): Map
fn (urls: Vec, options: Map, opts: Map): Map
POST /contents - Clean page text for URLs (or Exa result ids). The
2-arity form takes contents options such as {text: {maxCharacters: 5000}, highlights: true, maxAgeHours: 0}. Returns {results: [{url, title, text}], statuses}.
Example
out ::exa/get-contents(["https://hot.dev"])
first(out.results).text
// Capped text with highlights, freshly crawled
fresh ::exa/get-contents(["https://hot.dev"], {
text: {maxCharacters: 5000},
highlights: true,
maxAgeHours: 0
})
fresh.statuses
exa.api.key
post
fn (path: Str, body: Map): Any
fn (path: Str, body: Map, api-key: Str?): Any
fn (path: Str, body: Map, opts: Map): Any
POST a JSON body to an Exa path and return the decoded response. Use it
for endpoints this package does not wrap. Null body values are dropped.
The optional third argument is an opts Map or an API key. A failed
call is an Err carrying ::exa::http/HttpError.
Example
out ::exa/post("/answer", {query: "What is the Hot language?", text: true})
out.answer
search
fn (query: Str): Map
fn (query: Str, options: Map): Map
fn (query: Str, options: Map, opts: Map): Map
POST /search - Exa search. options: type ("auto" default,
"lite", "deep-lite", "deep"), numResults (1-100), category
("company", "news", "people", ...), includeDomains/
excludeDomains, startPublishedDate/endPublishedDate (ISO
8601), and contents ({text: {maxCharacters: 2000}},
{highlights: true}, {summary: {}}) to return page content
inline. Null options are dropped. Returns
{results: [{title, url, text?, highlights?, summary?}], ...}.
Example
out ::exa/search("startups building sql runtimes", {
numResults: 5,
contents: {text: {maxCharacters: 2000}}
})
map(out.results, (r) { r.url })
exa.api.key