Exa Contents: Extract Pages from Known URLs and Check the Output
Send known URLs to Exa Contents, read results and statuses per URL, check them against the pages, then store the output and clear the API key.
Task and deliverable · Prepare the input and environment · Mechanism and data flow
At a glance
With a known list of URLs, use Exa’s contents endpoint to retrieve text, verify each URL and save the response. The official page provides curl, Python and JavaScript examples. This article preserves the official curl and separately labels editorial adaptations for requesting text, capturing HTTP status and saving the response. No API was called in this batch; verification, stopping and cleanup conditions are editorial recommendations.
Task workflow
Known URLs go to the contents endpoint
The page documents
POST https://api.exa.ai/contentsas the call that returns full page contents, summaries and metadata for a list of URLs. It answers from Exa's cache and falls back to live crawling for pages that are not cached. The body takes eitherurlsorids, never both.urlsholds 1 to 100 strings of 1 to 2048 characters each, andidsholds document IDs obtained from searches. This tutorial usesurlsonly, because the starting point is a list you already have rather than a search query.Request fields decide what comes back
text,highlights,summaryandextrasselect the content requested. The documented defaults fortextandhighlightsarefalse; each accepts a boolean or an options object. The official curl sets onlyhighlights: trueand does not request body text. The editorial adaptation below sets bothtext: trueandhighlights: true, so both become requested fields to check.maxAgeHoursranges from -1 to 720: 0 returns live content crawled within the last 60 seconds, while -1 always uses cache.livecrawlTimeoutdefaults to 10000 milliseconds and has a maximum of 90000.snapshotAsOfreturns only stored versions and does not crawl the live page;subpagesdefaults to 0.Results and per-URL statuses
A 200 response has
requestId,results,statuses,costDollars,searchTimeand a deprecatedcontext. Each item inresultscan carrytitle,url,id,text,highlights,summary,publishedDate,authorand more, and the page's JSON sample shows these only as placeholders.statusesgives status information for each requested URL or document ID, withid,status,sourceand anerrorholdingtagandhttpStatusCode. The sample showssuccessandcachedas values, but the page does not list every possible value.costDollarsis an estimate. Request-level failures use 400, 401, 402, 403, 429, 500 or 503, with a body containingrequestId,errorandtag, and the page does not explain each code.Checking is an editorial layer
The page defines no completion check. The checks below are editorial recommendations, not Exa behavior: compare input URLs with returned
urlvalues andstatuses, confirm the field you asked for is present and not empty, and open the original page to confirm that any text or highlight matches what you intend to cite. A returnedtextshows what was extracted, not that the page's claims are true. The same goes for stopping: the page documents no cancel parameter for this endpoint, so this article uses interruption of the local process as an editorial control step.
Task and deliverable
With a known list of URLs, use Exa’s contents endpoint to retrieve text, verify each URL and save the response. The official page provides curl, Python and JavaScript examples. This article preserves the official curl and separately labels editorial adaptations for requesting text, capturing HTTP status and saving the response. No API was called in this batch; verification, stopping and cleanup conditions are editorial recommendations.
Prepare the input and environment
- An Exa account and API key. The page says you create a key in the dashboard and that new accounts start with free credits; current pricing is not covered here.
- A shell with
curland network access toapi.exa.ai, with the environment variableEXA_API_KEYset in the current session, because the supplied code reads the key from it. - A list of known URLs, 1 to 100 entries of 1 to 2048 characters each, kept in your own file so you can compare it with the response afterward.
- A dedicated working directory for request and response files, plus a way to open the original pages. The official command prints its response; the editorial wrapper below reads
request.json, saves the complete body toresponse.json, and prints curl’s exit status separately from HTTP status.
Mechanism and data flow
Known URLs go to the contents endpoint: The page documents POST https://api.exa.ai/contents as the call that returns full page contents, summaries and metadata for a list of URLs. It answers from Exa's cache and falls back to live crawling for pages that are not cached. The body takes either urls or ids, never both. urls holds 1 to 100 strings of 1 to 2048 characters each, and ids holds document IDs obtained from searches. This tutorial uses urls only, because the starting point is a list you already have rather than a search query.
Request fields decide what comes back: text, highlights, summary and extras select the content requested. The documented defaults for text and highlights are false; each accepts a boolean or an options object. The official curl sets only highlights: true and does not request body text. The editorial adaptation below sets both text: true and highlights: true, so both become requested fields to check. maxAgeHours ranges from -1 to 720: 0 returns live content crawled within the last 60 seconds, while -1 always uses cache. livecrawlTimeout defaults to 10000 milliseconds and has a maximum of 90000. snapshotAsOf returns only stored versions and does not crawl the live page; subpages defaults to 0.
Results and per-URL statuses: A 200 response has requestId, results, statuses, costDollars, searchTime and a deprecated context. Each item in results can carry title, url, id, text, highlights, summary, publishedDate, author and more, and the page's JSON sample shows these only as placeholders. statuses gives status information for each requested URL or document ID, with id, status, source and an error holding tag and httpStatusCode. The sample shows success and cached as values, but the page does not list every possible value. costDollars is an estimate. Request-level failures use 400, 401, 402, 403, 429, 500 or 503, with a body containing requestId, error and tag, and the page does not explain each code.
Checking is an editorial layer: The page defines no completion check. The checks below are editorial recommendations, not Exa behavior: compare input URLs with returned url values and statuses, confirm the field you asked for is present and not empty, and open the original page to confirm that any text or highlight matches what you intend to cite. A returned text shows what was extracted, not that the page's claims are true. The same goes for stopping: the page documents no cancel parameter for this endpoint, so this article uses interruption of the local process as an editorial control step.
Workflow map
| Stage | What happens |
|---|---|
| Known URLs go to the contents endpoint | The page documents POST https://api.exa.ai/contents as the call that returns full page contents, summaries and metadata for a list of URLs. |
| Request fields decide what comes back | text, highlights, summary and extras select the content requested. |
| Results and per-URL statuses | A 200 response has requestId, results, statuses, costDollars, searchTime and a deprecated context. |
| Checking is an editorial layer | The page defines no completion check. |
Complete the task
Prepare the account, key and environment:Create an API key in the Exa dashboard; the page says new accounts start with free credits, and this tutorial gives no current pricing. Authentication uses the x-api-key header, and the page says Authorization: Bearer also works. The supplied excerpt reads the key from the shell variable $EXA_API_KEY, so export it in the session before sending. You also need a shell with curl and network access to api.exa.ai. The excerpt does not create or check the variable, so confirm it is set yourself.
Assemble the URL list:Write down the URLs you already know, remove duplicates, and keep between 1 and 100 entries, each at most 2048 characters. Use the urls field and leave ids out. The supplied excerpt contains one placeholder, <url>, which you replace in your own copy; add more strings to the array for more pages. Keep the list in a file of your own so you can compare it with the response later. The page does not say how redirects, duplicates or unreachable pages are treated, so do not assume a page is reachable or that it comes back whole.
Choose the requested content: this task saves body text. Save the editorial JSON below as request.json, replace <url> with your own public URL, and add other URLs to the array if needed. Keep text: true and highlights: true to request both fields. The unchanged official curl is shown separately and requests snippets only. Leave freshness settings out unless needed; if setting maxAgeHours or snapshotAsOf, check the cache boundaries described above.
Send and save: in the same working directory, run the editorial shell wrapper below to read request.json. It writes the response body to response.json, captures HTTP status through curl’s --write-out, and separately captures curl’s exit status. These are command-wrapper values, not Exa response fields. Check curl’s status first: if nonzero, record the transport issue and stop; do not treat a possibly partial response as complete JSON. With a successful transfer and HTTP 200, open response.json and continue per-URL checks. Handle other HTTP outcomes in the next step. This batch did not execute the command.
Classify the HTTP outcome:If the call returns 200, continue to the per-URL checks. If it returns 400, 401, 402, 403, 429, 500 or 503, the page shows a body with requestId, error and tag; record all three and stop. Do not retry in a loop: the page text gives no retry rules or per-code guidance, so decide on retries yourself, as an editorial matter. Keep requestId with your notes.
Verify each URL: check statuses against the input list first, then find the corresponding url among the results actually returned. The docs specify status information for each requested URL or document ID, but do not guarantee a usable result for a failed URL. Do not use an absent result. Verify how status id relates to URL input in the actual response rather than guessing its format. Use success as this article’s editorial adoption threshold and retain other states or errors for review. Record error.tag and error.httpStatusCode only when present. For a missing entry or manual mismatch without those fields, record the URL and reason.
Compare with the original page and save:Open the original page for each URL you intend to cite and compare it with the returned text or highlights: title, a few distinctive phrases, and whether the passage is cut off. A mismatch means the extraction needs review, not that the page is wrong. Save the full JSON response with requestId, the date and your input list. Keep costDollars as an estimate. A saved snippet is not proof of a claim; it shows only what the API returned for that URL.
Stop and clean up:Whatever the outcome, finish with the same cleanup. If you interrupt the process yourself, the page documents no cancel call for this endpoint, so do not assume the server stopped work or that you were not charged. Unset EXA_API_KEY in the shell session, delete scratch files you do not need to keep (responses can hold page text), and make sure the key is not in shell history, screenshots or shared notes. If a key was exposed, the page's navigation lists key rotation, revocation and deletion operations under Team Management, but their behavior is not described on this page, so read those pages first.
Worked example
This is a hypothetical illustration; no response was observed in this batch. Put three public documentation URLs in the editorial request.json with text: true and highlights: true. After sending, retain the full response.json and the two statuses printed by the wrapper. Continue only after a successful transfer and HTTP 200: inspect statuses per input first, then find results actually present. If two statuses are success with usable text, compare that text with the original pages. If the third URL fails and has no usable result, retain its URL, status and actual error fields; do not expect it to have a results entry. Save the verification record, then clear keys and scratch files no longer needed. The official curl, body-text request and command wrapper are separately attributed below.
curl -X POST https://api.exa.ai/contents \
-H "x-api-key: $EXA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"<url>"
],
"highlights": true
}'request.json and replace the URL placeholder{
"urls": ["<url>"],
"text": true,
"highlights": true
}http_code=$(curl -sS -X POST https://api.exa.ai/contents \
-H "x-api-key: $EXA_API_KEY" \
-H "Content-Type: application/json" \
--data @request.json \
--output response.json \
--write-out '%{http_code}')
curl_status=$?
printf 'curl_status=%s http_code=%s\n' "$curl_status" "$http_code"Check the result and failure paths
- Static check before sending (editorial recommendation, not official behavior): confirm the body is valid JSON,
urlshas 1 to 100 strings of at most 2048 characters,idsis absent,EXA_API_KEYis set and the content field you want is included. - Success condition (editorial): the call returns 200, every input URL has a
successstatus, each requested field is non-empty, and your manual comparison with the original page matches. This is an editorial standard, not an official one. - Failure checks (editorial): record curl status for transport failures. For request-level HTTP errors, retain only the
requestId,errorandtagactually present. For per-URL errors, recorderror.taganderror.httpStatusCodewhen present. For missing results or manual mismatches, record the URL and reason without inventing API error fields, and do not adopt that result. - Empty-output checks apply only to requested fields. This task requests both
textandhighlights; retain a URL for review if a required field is empty or absent. If you adapt the request to select just one field, do not require an unrequested field to appear. Empty fields do not prove the original page has no content. - User stop and cleanup (editorial manual control, no official cancel API): if you interrupt the command by hand, discard the partial output and do not reuse it, and rerun only after checking the key and URL list. Success, failure, empty output and stopping all end with the same cleanup: unset
EXA_API_KEY, delete scratch files you do not need, and clear any key that may appear in shell history.
Scope and limits
- No Exa call, installation or execution happened in this batch. The JSON response on the page is a placeholder structure, not real output, and returned text cannot prove facts stated on a page.
- This article does not expand on
ids,subpages,summary,extras,entities, enterprisecompliancemodehipaaoruserIdentifier, and avoids the deprecatedcontext,livecrawlandcrawledBeforeDate. The official page also supplies Python and JavaScript SDK examples. This article selects its curl; unselected code is not missing from the source. - The page gives no current pricing, rate limits, version support or guarantee that a page is reachable, and this tutorial promises none of them.
- The official curl requires a shell, curl, an environment key and network access. It requests only
highlightsand does not save output or handle errors. The separately labeled editorial adaptation addstext: true, a response file and status capture. Neither wrapper execution nor semantic correctness was verified in this batch.
No product or API was run in this batch, nothing was installed, no account was logged in and no real response was observed. API behavior comes from the documentation examples on the official page s1; completion checks, error and stop decisions and key cleanup are editorial recommendations, not official behavior.
Article sources
Original editorial content; official descriptions and checking suggestions are distinguished.