Get data from an API
The YouTube API in the agent-data catalog returns video titles, channels, durations, and URLs. This guide uses one search for python programming through CLI, HTTP, or MCP.
The captured result includes a Python lesson from Indently, lasting 10 minutes and 30 seconds. The CLI is the recommended starting method.
Before you start
Section titled “Before you start”You need an agent-data account with available call allowance or credits. Choose a method below. Your tab selection applies throughout the page.
You need Node.js 22.20.0 or later and npm. The examples use agent-data 0.13.0 on Node.js 22.23.4.
For a coding agent:
- Run setup for your agent. This command selects Codex.
npx --yes agent-data@latest init --codex- Complete browser approval.
- Restart your coding agent.
For another agent, select its setup flag.
For direct terminal use:
- Install the CLI.
- Start browser approval.
npm install -g agent-data@latestagent-data auth login- Complete browser approval.
Check the installed version and credential.
agent-data --versionagent-data auth statusThis November 14, 2026 response excerpt omits identity, balances, and credential details.
{ "status": "authenticated", "account": { "authenticated": true, "can_make_calls": true }}authenticated means the service accepted the credential. can_make_calls reports account eligibility at that time. See authentication recovery if this check fails.
Give your coding agent this task. For direct terminal use, follow the three steps below.
Use agent-data to find YouTube videos about "python programming".Use curl in Bash or zsh. Supply your API key through AGENT_DATA_API_KEY as described in authentication.
Search and contract requests use the marketplace address. Data requests use api.base_url from the API contract. Use the returned address if it differs from the captured example.
Connect a client with Streamable HTTP MCP support to this URL.
https://agent-data.motie.dev/mcp- Complete MCP setup.
- Check that
search,docs, andcallappear in the tool list. - Invoke the tools below through your agent or tool inspector.
The JSON examples contain tool arguments.
Procedure
Section titled “Procedure”1. Find an API
Section titled “1. Find an API”Search for the operation you need. This request finds APIs, not video records.
agent-data search "YouTube video search and details" --limit 3curl --fail-with-body --silent --show-error --get \ -H "Authorization: Bearer $AGENT_DATA_API_KEY" \ --data-urlencode 'q=YouTube video search and details' \ --data-urlencode 'limit=3' \ 'https://agent-data.motie.dev/api/v2/marketplace/search'Call the search tool.
{ "query": "YouTube video search and details", "limit": 3}The November 14, 2026 response includes this direct match. The excerpt omits other metadata, related results, and pagination fields.
{ "direct": { "listings": [ { "id": "e5182587-a7c9-4668-a8a6-314458afef40", "name": "YouTube API", "handle": "youtube-com", "short_description": "Search YouTube videos and retrieve public video and channel metadata live." } ] }}The API handle youtube-com is a readable identifier. The listing ID e5182587-a7c9-4668-a8a6-314458afef40 identifies the same catalog entry. CLI commands accept either value.
direct.listings contains matches to the requested API or operation. related.listings contains similar suggestions. See search results for their meanings.
2. Inspect the operation and inputs
Section titled “2. Inspect the operation and inputs”Read the YouTube API contract.
agent-data docs youtube-comcurl --fail-with-body --silent --show-error \ -H "Authorization: Bearer $AGENT_DATA_API_KEY" \ 'https://agent-data.motie.dev/api/v1/marketplace/listings/youtube-com/docs'Call the docs tool.
{ "listing_id": "youtube-com"}Check that the API has the operation and response fields your task needs. Find search-videos in api.routes. The captured contract contains these values.
| Contract value | Meaning |
|---|---|
slug: "search-videos" | The route slug names the search operation. |
method: "GET" | The request uses HTTP GET. |
path: "/v1/search-videos" | Append this path to api.base_url. |
name: "query", in: "query", required: true, type: "string" | Supply search text in the URL query string. |
request_body: null | The request has no body. |
The contract checked on November 17, 2026 returns https://api.agent-data.dev/youtube-com. The current catalog contract supplies the address for your request.
3. Call it with the required input
Section titled “3. Call it with the required input”- Preview the request.
agent-data call youtube-com search-videos --query "python programming" --dry-runThe preview resolves GET with query=python+programming and no body. It does not request video data.
- Execute the data request.
agent-data call youtube-com search-videos --query "python programming"Execute the data request.
curl --fail-with-body --silent --show-error --get \ -H "Authorization: Bearer $AGENT_DATA_API_KEY" \ --data-urlencode 'query=python programming' \ 'https://api.agent-data.dev/youtube-com/v1/search-videos'The response body contains the video data.
Call the call tool.
{ "listing_id": "youtube-com", "route": "search-videos", "params": { "query": "python programming" }}Read the JSON in the result’s text content. structuredContent.http_response also contains the HTTP response details.
If the query is missing
Section titled “If the query is missing”Without query, the CLI reports missing_required_param: Missing required parameter: query (in: query). Add --query "python programming" to correct the request. The call reference shows the actual error payload and correction.
Read your result
Section titled “Read your result”The CLI returned this first video on November 14, 2026. HTTP and MCP returned it on November 17, 2026.
The excerpt retains seven fields from the first item. It omits other fields, other items, and next_cursor.
{ "items": [ { "video_id": "fWjsdhR3z3c", "title": "Learn Python in Less than 10 Minutes for Beginners (Fast & Easy)", "channel_name": "Indently", "duration": "10:30", "duration_seconds": 630, "publication_information": "5 years ago", "video_url": "https://www.youtube.com/watch?v=fWjsdhR3z3c" } ]}| Field | Meaning |
|---|---|
items | The returned video records. |
video_id | The video’s identifier. |
video_url | The URL for the video. |
duration_seconds | Duration as a number of seconds. |
duration | Duration as source text. |
publication_information | Relative source text, not an exact publication date. |
next_cursor | A value for the next page, or null when the source reports no more results. |
Use a returned next_cursor unchanged with the same query. The public captures omit this value. See the contract constraints before another request.
The November 14 CLI call returned 14 items. The November 17 HTTP and MCP calls returned 13 and 11 items. Source results and page sizes can vary.
Download the complete captured items: CLI response, HTTP response, and MCP response. Each capture records its date, interface, and omissions.
Use the returned data
Section titled “Use the returned data”You used a catalog identifier to read an API contract, then called its search operation. Your application or agent can use the returned video records.
Browse the catalog without a query
Section titled “Browse the catalog without a query”Use agent-data list when you want to explore published APIs without search ranking.
agent-data list --limit 3The captured browse result includes the StockX API, identified by stockx-com. Read its contract before a data call. The catalog reference includes the real response, HTTP and MCP requests, filters, and pagination.
If no result fits
Section titled “If no result fits”| What you see | What to do |
|---|---|
| Search reports incomplete results. | Retain the failure. Retry the affected read. |
| A result matches the website but lacks your operation. | Extend the API. |
| The catalog has no API for the website. | Build an API. |
| Authentication or input validation fails. | Follow troubleshooting. |
Check both result groups and candidate contracts before you request a build.
Related tasks
Section titled “Related tasks”Use request inputs for path parameters or JSON bodies. Build an API for a missing website. Extend an API for a missing operation.
Use email notifications to send a result to your account’s email address.