REST API Content Retrieval
Overview
REST API content retrieval is a technique for obtaining the body or full contents of one or more resources (such as documents, URLs, or publications) by calling a dedicated REST endpoint on a web API. Instead of returning search results or metadata, the endpoint resolves the supplied identifiers and returns the actual content associated with each one.
Mechanism
The technique typically follows these steps:
- The client prepares an HTTP POST request to a dedicated contents endpoint.
- The request includes authentication credentials (commonly an API key supplied via a custom header such as
x-api-key). - The request body is JSON-encoded and contains an
idsfield listing one or more resource identifiers (for example, canonical URLs of the desired pages or publications). - The server responds with the resolved content for each requested identifier.
Example: Exa API /contents Endpoint
The Exa API implements REST API content retrieval through its /contents endpoint. A request is sent as POST https://api.exa.ai/contents with the resource identifiers passed in a JSON ids array:
bash
curl -X POST "https://api.exa.ai/contents"
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"ids": ["https://exa.ai/library/publication/ymvqpsm8045"]
}'
In this pattern, the caller supplies a single URL (or a list of URLs) inside ids, and the Exa service returns the corresponding document contents. Because the endpoint accepts multiple identifiers in one request, it can be used to batch-fetch contents for several resources in a single call.
Characteristics
- Stateless: Like other REST interactions, each request is self-contained and authenticated independently.
- Identifier-driven: Retrieval is keyed by resource IDs supplied by the client, rather than by a free-text query.
- Batch-friendly: Multiple identifiers can typically be supplied in a single
idsarray to retrieve many contents at once. - Auth via header: API access is usually gated by an
x-api-keyheader rather than query-string credentials.
Implementations
- Exa API — exposes a
/contentsPOST endpoint that takes anidsarray of URLs and returns their contents.