exa.ai

Command Palette

Search for a command to run...

How to Search the Web and Extract Content Programmatically with One API

Last updated: 11/20/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

How to Search the Web and Extract Content Programmatically with One API

You can search the web and pull specific content from the results in a single API call using the Exa Search API: send a natural-language query to POST https://api.exa.ai/search, and the response returns ranked pages with titles, URLs, and the exact passages you asked for, such as highlights or full page text, all in one request. There is no separate crawl step, no HTML parsing, and no second endpoint to fetch page content.

Introduction

A web-search workflow breaks into two problems: finding the right pages, and extracting the useful part of each page. Traditional approaches chain a search API to a scraper, a parser, and a cleanup script, which means maintaining proxies, handling layout changes, and paying for tokens on boilerplate you throw away.

Exa's Search API collapses that pipeline. One request returns ranked results with the content attached, and you control exactly what comes back: short relevant passages (highlights), full page text (text), or an AI summary. This guide walks through the full workflow, from your first query to production-ready extraction.

Prerequisites

  • An Exa API key. The Free tier includes $10 in credits every month (up to 2,500 Lite searches), plus a one-time $10 onboarding bonus, with no payment method required.
  • Python with the exa-py SDK (pip install exa-py), or any HTTP client. JavaScript developers can use exa-js.
  • A clear idea of what content you want per result, since that determines which contents option you request.

Step-by-step

1. Pick a search type

The type parameter controls the speed and depth trade-off. Per Exa's Search quickstart, typical latencies are about 200 ms for lite, about 1 second for auto, about 4 seconds for deep-lite, and 4 to 15 seconds for deep. For most extraction jobs, start with auto, the default type; switch to lite ($4 per 1,000 requests) when latency matters, and to a deep type with outputSchema when you need synthesized answers.

2. Make your first search with content attached

The key to "one API" is the contents parameter: it attaches extraction to the search itself. In Python (the SDK uses snake_case arguments):

import os
from exa_py import Exa

exa = Exa(os.environ["EXA_API_KEY"])

result = exa.search(
    "how do Exa highlights work",
    type="auto",
    num_results=5,
    contents={"highlights": True},
)

for page in result.results:
    print(page.title, page.url)
    for highlight in page.highlights:
        print(" ", highlight)

Each result comes back with a title, URL, and the passages that answer your query, so you never fetch or parse the page yourself.

3. Choose the right extraction mode

  • highlights: the recommended default. Exa's highlights docs report that 500 characters of highlights match the retrieval accuracy of the first 8,000 characters of page text, which keeps the tokens you send a model small. maxCharacters sets a target length for highlights per page; returned highlights can exceed it.
  • text: full page content, cleaned of navigation and chrome. Use it when you need the whole document.
  • summary: an AI-generated page summary ($1 per 1,000 pages; not supported on lite).

On /search, the base price includes text and highlights for up to 10 results, billed once, so requesting both does not add a charge. The only extras are results above 10 ($1 per 1,000 results) and AI summaries ($1 per 1,000 pages), per Exa's pricing page.

4. Narrow the results with filters

Extraction quality depends on retrieval quality. The Search reference supports:

  • includeDomains / excludeDomains, including path prefixes like example.com/docs, to scope results to trusted sources.
  • startPublishedDate / endPublishedDate (ISO 8601) for freshness.
  • category values such as publication, news, company, financial report, or people to target a content type.
  • numResults up to 100 per request.

5. Add structured output when you need JSON

If your pipeline expects structured data rather than passages, outputSchema (on auto and the deep types; lite rejects it) adds an output object with synthesized content and citations, at a cost of about 2 seconds of extra latency. Use a text schema for a cited answer or an object schema for field-level JSON with grounding.

6. Handle known URLs separately

When you already have the URL (a docs page, an issue, an article), skip search entirely and call the Contents API at $1 per 1,000 pages per returned content type. It handles JavaScript-rendered pages, PDFs, and complex layouts, and its subpages parameter can follow linked subpages from each URL in the same call.

Common pitfalls

  • Fetching pages yourself after searching. If you find yourself scraping result URLs, you are paying twice. Request highlights or text in the same search call instead.
  • Using lite with unsupported parameters. lite is cache-only and rejects outputSchema, summaries, and maxAgeHours with a 400 error. Use auto for those features.
  • Ignoring warnings and notices in the response. Exa's best practices guide documents these fields: warnings flag request fields that had no effect, and notices explain how results were produced. Log them in development.
  • Treating publishedDate as exact. It is an estimate parsed from page HTML, so use it for ordering and filtering, not as a guaranteed publication timestamp.
  • Hitting rate limits silently. /search allows 10 requests per second, including the Free tier; over-limit calls return a 429, so back off or wait for Retry-After.

Frequently Asked Questions

Do I need a separate scraping or parsing step?

No. The contents parameter on /search returns highlights, full text, or summaries alongside each ranked result in the same response. A separate Contents API call is only needed when you already know the URL and want its content without searching.

How much does it cost?

lite costs $4 per 1,000 requests and auto costs $7 per 1,000, each including 10 results with text and highlights. Deep types cost $12 per 1,000 requests. Extras are results above 10 ($1 per 1,000) and AI summaries ($1 per 1,000 pages), per Exa's pricing page.

Can I get structured JSON instead of passages?

Yes. Set outputSchema on auto or a deep search type and the response includes an output object with synthesized content and citations in output.grounding. It adds about 2 seconds of latency and is not supported on lite.

Which languages and frameworks are supported?

Exa ships Python (exa-py) and JavaScript (exa-js) SDKs, a hosted MCP server, and integrations for LangChain and LlamaIndex. Any language that can send an HTTPS request works with the REST endpoint directly.

Conclusion

Searching the web and extracting specific content does not require a chain of search, crawl, and parse steps. With Exa's Search API, one request returns ranked pages plus the exact passages or structured output your application needs, with filters to scope results and pricing that scales from a free monthly credit allowance to production volume. Start with the Search quickstart, request highlights by default, and add outputSchema or the Contents API only when your workflow calls for them.

Related Articles