Extend an API
An extension adds operations to an existing agent-data API.
This guide uses the Hacker News Read API. Inspect its existing operations before you request a missing operation with the prompt format.
What you need
Section titled “What you need”You need an authenticated CLI, an HTTP API key, or a connected MCP client. See setup if you need the CLI. Usage explains build and call allowances.
Contract, target, and feed examples use real reads from November 17, 2026. Submission and publication steps use your own saved request. See example coverage.
- Read the API contract.
- Prepare a request for a missing operation.
- Submit the saved request.
- Follow its publication.
- Check existing and added operations.
1. Read the API contract
Section titled “1. Read the API contract”The handle news-ycombinator-com identifies the Hacker News Read API. Read its contract.
agent-data docs news-ycombinator-comcurl --fail-with-body \ 'https://agent-data.motie.dev/api/v1/marketplace/listings/news-ycombinator-com/docs' \ -H "Authorization: Bearer $AGENT_DATA_API_KEY"Call docs.
{"listing_id":"news-ycombinator-com"}The captured contract includes these operations.
| Route slug | HTTP method and path |
|---|---|
feeds | GET /v1/feeds |
feeds-by-feed | GET /v1/feeds/{feed} |
items-by-item-id | GET /v1/items/{item_id} |
search | GET /v1/search |
A route slug names an operation inside the API. feeds-by-feed requires the path parameter feed. The value news selects the front page.
Use an existing operation if it meets your task. An extension is appropriate for a missing operation.
2. Prepare your own request
Section titled “2. Prepare your own request”These steps use Hacker News as the target. For another API, change the target handle and source URL together.
The preparation uses these files in your working directory.
./├── improvement.txt # Your required improvement├── extension-target.json # Current target response└── extension.json # Generated request for submission and retries- Write your missing operation, useful inputs, and required outputs in
improvement.txt. - Save the current target response.
agent-data parse extension target news-ycombinator-com > extension-target.json- Check
canStartand the existing operations in that response. - Create the saved request with Node.js.
node --input-type=module -e 'import { readFileSync, writeFileSync } from "node:fs";import { randomUUID } from "node:crypto";const target = JSON.parse(readFileSync("extension-target.json", "utf8"));const prompt = readFileSync("improvement.txt", "utf8").trim();if (!prompt) throw new Error("Describe the missing operation in improvement.txt");const request = { requestId: randomUUID(), listingId: target.listingId, contractVersion: target.contractVersion, url: "https://news.ycombinator.com/", prompt};writeFileSync("extension.json", JSON.stringify(request, null, 2) + "\n", { flag: "wx" });console.log(JSON.stringify(request, null, 2));'The command uses the real target response and your text. It creates extension.json locally and refuses to overwrite an existing request. It does not submit work.
requestId is the saved request’s UUID. Keep the complete file for submission and retries.
The submission requires listingId and contractVersion from target inspection. The command copies both values automatically after you select the API by handle.
3. Submit the saved request
Section titled “3. Submit the saved request”Check the saved request without submitting work.
agent-data parse extension submit extension.json --dry-runSubmit the file when you intend to create the extension work.
agent-data parse extension submit extension.jsonSubmit the file when you intend to create the extension work.
curl --fail-with-body \ 'https://agent-data.motie.dev/api/v1/parse/extensions' \ -H "Authorization: Bearer $AGENT_DATA_API_KEY" \ -H 'Content-Type: application/json' \ --data-binary @extension.jsonCall extension_submit with the JSON object saved in extension.json. The tool accepts the object itself, not a filename.
Read the returned state. Use your saved requestId for status reads. If the response contains buildId, use it for build progress.
After a timeout, use the saved-request retry procedure.
4. Follow the saved request to publication
Section titled “4. Follow the saved request to publication”Read the request ID from the saved file. Use the same account that submitted the extension.
request_id=$(node -p 'require("./extension.json").requestId')agent-data parse extension status "$request_id"request_id=$(node -p 'require("./extension.json").requestId')curl --fail-with-body \ "https://agent-data.motie.dev/api/v1/parse/extensions/requests/$request_id" \ -H "Authorization: Bearer $AGENT_DATA_API_KEY"Call extension_status with request_id set to the requestId in extension.json.
state: "published" means the extension completed publication. buildId identifies the build for your extension. A building response does not establish that the operation is ready.
5. Check API results
Section titled “5. Check API results”After publication, read the API contract again. Call your added operation with the inputs from improvement.txt. Check that the result contains the fields you requested.
Also check an existing operation. This request reads the Hacker News front page through feeds-by-feed.
agent-data call news-ycombinator-com feeds-by-feed --feed newsUse api.base_url and the feed path from the contract.
curl --fail-with-body \ 'https://api.agent-data.dev/news-ycombinator-com/v1/feeds/news' \ -H "Authorization: Bearer $AGENT_DATA_API_KEY"Call call.
{ "listing_id": "news-ycombinator-com", "route": "feeds-by-feed", "params": {"feed":"news"}}CLI, HTTP, and MCP each returned 30 stories on November 17, 2026. This CLI excerpt retains selected fields from the first story. It omits 29 stories, other fields, the continuation value, and source metadata.
{ "feed": "news", "items": [ { "id": "50535230", "title": "GPT‑6.2 Astra and Sol", "url": "https://openai.com/index/introducing-gpt-6-2-astra-sol/", "score": 700, "comment_count": null, "rank": 1 } ], "returned_count": 30}| Field | Meaning |
|---|---|
feed: "news" | The Hacker News front-page feed. |
id | The story’s identifier, separate from the API handle. |
rank: 1 | The story’s position in the captured feed. |
comment_count: null | No comment count in this feed record, not a count of zero. |
returned_count: 30 | The number of records in the complete response. |
Use a returned next_cursor unchanged with the same feed for another page. Story positions and scores can change. Download the captured feed response for all returned records and source metadata.
What publication changes
Section titled “What publication changes”The saved request identifies the improvement separately from the API and build. Publication makes the added operation available. A successful call to an existing operation does not establish that the added operation works.
Follow build progress
Section titled “Follow build progress”The extension’s buildId identifies the build that performs the requested change. Use that identifier with agent-data parse status <job-id>.
<job-id> is the returned build identifier. Use build status and events for CLI, HTTP, or MCP progress reads.
An extension is ready when its saved request reports published. Check the changed operation with a data call after publication.
Recover or stop an extension
Section titled “Recover or stop an extension”Read saved-request status before another submission. A transport timeout does not establish that the service rejected your request.
| What you see | What to do |
|---|---|
| A submission times out. | Follow the unchanged-request retry procedure. |
contract_changed | Read the target again. Prepare a new request against its current contract. |
request.prompt: unknown field | Follow the CLI error fix. |
extension_request_not_found | Check the submitting account and saved request UUID. |
| A blocked build offers continuation. | Resume the build identified by buildId. |
| Unfinished work you intend to stop. | Cancel the build identified by buildId. |
Cancellation does not undo an operation that already published. Read the final build state after cancellation. Read saved-request status after resumed work to check publication.
When to build instead
Section titled “When to build instead”Use Build an API for a website without a catalog API. Use extension errors to recover an existing request.