---
name: tona-data
description: Query verified social, ad, ecommerce, shopping, and news market data through a Tona workspace via REST or remote MCP.
---

# Tona Data Gateway Skill

Obtain `TONA_URL` (for example `https://tona.app`) and `TONA_KEY` (`tona_...`) from the user environment.

## Readiness Checklist Before First Paid Call

1. **Discover catalog (free)**: Read `GET $TONA_URL/api/v1/tools` or `GET $TONA_URL/api/v1/openapi.json` to inspect schemas, returned fields, page limits, availability, and per-page credit prices.
2. **Select services**: Ensure the workspace owner has enabled the needed service at `$TONA_URL/workspace/services/{id}`.
3. **Issue agent key**: Create an active `tona_...` key at `$TONA_URL/workspace/keys`.
4. **Verify workspace readiness & credits (free)**:

```sh
curl --fail-with-body "$TONA_URL/api/v1/workspace" \
  -H "Authorization: Bearer $TONA_KEY"
```

Confirm the target service is listed with `"status": "ready"` and `credits` covers `credits_per_page`. Follow `next_step` if any prerequisite is missing.

5. **Invoke via REST or remote MCP**:
   - **REST**: `POST $TONA_URL/api/v1/tools/{operation}` with `Authorization: Bearer $TONA_KEY`, `Content-Type: application/json`, and a unique `Idempotency-Key` header per logical page request.
   - **Remote MCP**: Connect a Streamable HTTP client to `$TONA_URL/api/mcp` with `Authorization: Bearer $TONA_KEY`, call `tools/list` to inspect active workspace tools, and pass `idempotency_key` in `tools/call` arguments for safe retries.

## Billing & Pagination Rules

- Each successful invocation returns one upstream page and charges credits_per_page, including valid empty pages (items: []). Failed upstream calls release the credit hold and charge 0 credits.
- Reuse the same `Idempotency-Key` (or `idempotency_key`) only when retrying the exact same tool and arguments. Sending different arguments with an existing key returns `409 idempotency_conflict`.
- Requesting the next page (`cursor` or `page`) is a new logical invocation and requires a new idempotency key.
- Services awaiting upstream contracts (such as `amazon_reverse_keywords` via Ziniao `https://open.ziniao.com/`) remain `unavailable` while workspace requests are `provisioning` and never return mock data or charge credits.
- Google sign-in authenticates your Tona workspace account only. Future Google Analytics 4 (GA4) access is a separate user-authorized OAuth data connection.

## Catalog Operations

### `x_search_posts` (X post search)
- Availability: ready
- Price: 0.0152 credits/page (empty pages billed: true)
- Page limit: one upstream response
- Input parameters: `query`, `cursor`
- Returned item fields: `id`, `text`, `url`, `author`, `likes`, `published_at`
- Sample REST request (`POST https://tona.app/api/v1/tools/x_search_posts`): `{"query":"wireless charger"}`
- Sample MCP `tools/call`: `{"name":"x_search_posts","arguments":{"query":"wireless charger","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0152","data":{"items":[{"id":"123","text":"Testing a wireless charger.","url":"https://x.com/i/status/123","author":"example","likes":7,"published_at":null}],"next_cursor":null}}`

### `x_user_profile` (X account profile)
- Availability: ready
- Price: 0.0152 credits/page (empty pages billed: true)
- Page limit: up to 1 items/page
- Input parameters: `username`
- Returned item fields: `id`, `username`, `name`, `bio`, `followers`, `following`, `url`
- Sample REST request (`POST https://tona.app/api/v1/tools/x_user_profile`): `{"username":"NASA"}`
- Sample MCP `tools/call`: `{"name":"x_user_profile","arguments":{"username":"NASA","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0152","data":{"items":[{"id":"123","username":"example","name":"Sample creator","bio":"Product reviews","followers":325,"following":54,"url":"https://x.com/example"}],"next_cursor":null}}`

### `x_user_timeline` (X account timeline)
- Availability: ready
- Price: 0.0152 credits/page (empty pages billed: true)
- Page limit: one upstream response
- Input parameters: `user_id`, `cursor`
- Returned item fields: `id`, `text`, `url`, `author`, `likes`, `published_at`
- Sample REST request (`POST https://tona.app/api/v1/tools/x_user_timeline`): `{"user_id":"11348282"}`
- Sample MCP `tools/call`: `{"name":"x_user_timeline","arguments":{"user_id":"11348282","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0152","data":{"items":[{"id":"123","text":"Testing a wireless charger.","url":"https://x.com/i/status/123","author":"example","likes":7,"published_at":null}],"next_cursor":null}}`

### `x_trending_topics` (X trending topics)
- Availability: ready
- Price: 0.0152 credits/page (empty pages billed: true)
- Page limit: one upstream response
- Input parameters: `country`
- Returned item fields: `rank`, `name`, `query`, `volume`, `location`, `as_of`
- Sample REST request (`POST https://tona.app/api/v1/tools/x_trending_topics`): `{"country":"US"}`
- Sample MCP `tools/call`: `{"name":"x_trending_topics","arguments":{"country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0152","data":{"items":[{"rank":1,"name":"#ProductLaunch","query":"#ProductLaunch","volume":null,"location":"United States","as_of":null}],"next_cursor":null}}`

### `x_search_communities` (X community search)
- Availability: ready
- Price: 0.0152 credits/page (empty pages billed: true)
- Page limit: one upstream response
- Input parameters: `query`, `cursor`
- Returned item fields: `id`, `name`, `topic`, `members`, `url`
- Sample REST request (`POST https://tona.app/api/v1/tools/x_search_communities`): `{"query":"ecommerce"}`
- Sample MCP `tools/call`: `{"name":"x_search_communities","arguments":{"query":"ecommerce","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0152","data":{"items":[{"id":"123","name":"Sample sellers","topic":"Commerce","members":350,"url":"https://x.com/i/communities/123"}],"next_cursor":null}}`

### `youtube_search_videos` (YouTube video search)
- Availability: unavailable (request access in the workspace)
- Price: 0.0047 credits/page (empty pages billed: true)
- Page limit: up to 20 items/page
- Input parameters: `query`, `cursor`
- Returned item fields: `id`, `title`, `url`, `channel`
- Sample REST request (`POST https://tona.app/api/v1/tools/youtube_search_videos`): `{"query":"wireless charger review"}`
- Sample MCP `tools/call`: `{"name":"youtube_search_videos","arguments":{"query":"wireless charger review","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0047","data":{"items":[{"id":"example0001","title":"Wireless charger comparison","url":"https://www.youtube.com/watch?v=example0001","channel":"Example channel"}],"next_cursor":null}}`

### `amazon_reverse_keywords` (Amazon ASIN reverse keywords)
- Availability: unavailable: pending upstream contract (Ziniao Open Platform: https://open.ziniao.com/)
- Price: unpriced (awaiting operator configuration) (empty pages billed: true)
- Page limit: pending upstream contract
- Input parameters: `marketplace`, `asin`, `cursor`
- Returned item fields: `keyword`, `search_volume`
- Sample REST request (`POST https://tona.app/api/v1/tools/amazon_reverse_keywords`): `{"asin":"B012345678","marketplace":"US"}`
- Sample MCP `tools/call`: `{"name":"amazon_reverse_keywords","arguments":{"asin":"B012345678","marketplace":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0","data":{"items":[{"keyword":"wireless charger","search_volume":null}],"next_cursor":null}}`

### `tiktok_search_videos` (TikTok video search)
- Availability: unavailable (request access in the workspace)
- Price: 0.0016 credits/page (empty pages billed: true)
- Page limit: up to 10 items/page
- Input parameters: `query`, `country`, `cursor`
- Returned item fields: `id`, `caption`, `creator`, `url`, `views`, `likes`
- Sample REST request (`POST https://tona.app/api/v1/tools/tiktok_search_videos`): `{"query":"wireless earbuds","country":"US"}`
- Sample MCP `tools/call`: `{"name":"tiktok_search_videos","arguments":{"query":"wireless earbuds","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0016","data":{"items":[{"id":"7400000000000000001","caption":"Earbuds on the commute","creator":"example","url":"https://www.tiktok.com/@example/video/7400000000000000001","views":12500,"likes":840}],"next_cursor":null}}`

### `tiktok_top_ads` (TikTok top ads)
- Availability: unavailable (request access in the workspace)
- Price: 0.0016 credits/page (empty pages billed: true)
- Page limit: up to 20 items/page
- Input parameters: `country`, `query`, `days`, `cursor`
- Returned item fields: `id`, `title`, `brand`, `objective`, `likes`
- Sample REST request (`POST https://tona.app/api/v1/tools/tiktok_top_ads`): `{"country":"US","days":30}`
- Sample MCP `tools/call`: `{"name":"tiktok_top_ads","arguments":{"country":"US","days":30,"idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.0016","data":{"items":[{"id":"7500000000000000001","title":"Sound for the commute","brand":"Example Audio","objective":"campaign_objective_video_view","likes":460}],"next_cursor":null}}`

### `amazon_search_products` (Amazon product search)
- Availability: unavailable (request access in the workspace)
- Price: 0.2 credits/page (empty pages billed: true)
- Page limit: up to 48 items/page
- Input parameters: `query`, `country`, `page`
- Returned item fields: `asin`, `title`, `url`, `price`, `rating`
- Sample REST request (`POST https://tona.app/api/v1/tools/amazon_search_products`): `{"query":"wireless earbuds","country":"US"}`
- Sample MCP `tools/call`: `{"name":"amazon_search_products","arguments":{"query":"wireless earbuds","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.2","data":{"items":[{"asin":"B09G9FPHY6","title":"Sample earbuds","url":"https://www.amazon.com/dp/B09G9FPHY6","price":"$59.99","rating":"4.5"}],"next_cursor":null}}`

### `amazon_product_details` (Amazon product details)
- Availability: unavailable (request access in the workspace)
- Price: 0.2 credits/page (empty pages billed: true)
- Page limit: up to 1 items/page
- Input parameters: `asin`, `country`
- Returned item fields: `asin`, `title`, `url`, `price`, `rating`, `availability`, `ratings_count`
- Sample REST request (`POST https://tona.app/api/v1/tools/amazon_product_details`): `{"asin":"B09G9FPHY6","country":"US"}`
- Sample MCP `tools/call`: `{"name":"amazon_product_details","arguments":{"asin":"B09G9FPHY6","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.2","data":{"items":[{"asin":"B09G9FPHY6","title":"Sample earbuds","url":"https://www.amazon.com/dp/B09G9FPHY6","price":"$59.99","rating":"4.5","availability":"In Stock","ratings_count":321}],"next_cursor":null}}`

### `amazon_product_reviews` (Amazon product reviews)
- Availability: unavailable (request access in the workspace)
- Price: 0.2 credits/page (empty pages billed: true)
- Page limit: up to 10 items/page
- Input parameters: `asin`, `country`, `page`
- Returned item fields: `id`, `title`, `text`, `stars`, `verified_purchase`
- Sample REST request (`POST https://tona.app/api/v1/tools/amazon_product_reviews`): `{"asin":"B09G9FPHY6","country":"US"}`
- Sample MCP `tools/call`: `{"name":"amazon_product_reviews","arguments":{"asin":"B09G9FPHY6","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.2","data":{"items":[{"id":"R123EXAMPLE","title":"Comfortable fit","text":"Stayed in place on my commute.","stars":"4","verified_purchase":true}],"next_cursor":null}}`

### `shopping_search_products` (Google Shopping product search)
- Availability: unavailable (request access in the workspace)
- Price: 0.2 credits/page (empty pages billed: true)
- Page limit: up to 10 items/page
- Input parameters: `query`, `country`
- Returned item fields: `id`, `title`, `store`, `price`, `offer_url`
- Sample REST request (`POST https://tona.app/api/v1/tools/shopping_search_products`): `{"query":"wireless earbuds","country":"US"}`
- Sample MCP `tools/call`: `{"name":"shopping_search_products","arguments":{"query":"wireless earbuds","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.2","data":{"items":[{"id":"example-product","title":"Wireless earbuds","store":"Example Audio","price":"$49.00","offer_url":"https://example.com/earbuds"}],"next_cursor":null}}`

### `news_search_articles` (Brand news search)
- Availability: unavailable (request access in the workspace)
- Price: 0.2 credits/page (empty pages billed: true)
- Page limit: up to 10 items/page
- Input parameters: `query`, `country`
- Returned item fields: `title`, `url`, `publisher`, `published_at`
- Sample REST request (`POST https://tona.app/api/v1/tools/news_search_articles`): `{"query":"retail media","country":"US"}`
- Sample MCP `tools/call`: `{"name":"news_search_articles","arguments":{"query":"retail media","country":"US","idempotency_key":"req_sample_001"}}`
- Sample response (illustrative reference only, not live data): `{"request_id":"sample_request","credits":"0.2","data":{"items":[{"title":"Retail media report","url":"https://example.com/retail-report","publisher":"Example News","published_at":"2026-03-01T12:00:00Z"}],"next_cursor":null}}`

## Diagnostic Error Codes

| Error code | HTTP | Meaning and next step |
| --- | ---: | --- |
| `invalid_agent_key` | 401 | Missing, malformed, or revoked Tona agent key. Issue an active key at /workspace/keys and pass Authorization: Bearer tona_<key>. |
| `unknown_tool` | 404 | Requested tool identifier does not exist in the catalog. Inspect GET /api/v1/tools for valid tool identifiers. |
| `invalid_arguments` | 400 | Input JSON did not match the tool input_schema. Validate arguments against input_schema in GET /api/v1/tools or GET /api/v1/openapi.json. |
| `invalid_idempotency_key` | 400 | Idempotency-Key header or idempotency_key argument was empty or longer than 200 characters. Pass a non-empty string up to 200 characters per logical page invocation. |
| `service_not_selected` | 403 | Service has not been enabled for this workspace. Open /workspace/services/{id} and enable the service for your workspace. |
| `upgrade_required` | 403 | Workspace tier does not meet the minimum_tier for this service. Check minimum_tier in GET /api/v1/workspace. |
| `provisioning` | 503 | Service is selected in this workspace but still awaiting operator credential verification, published price, or pending upstream contract. Poll GET /api/v1/workspace until the service status is "ready". 0 credits are charged. |
| `insufficient_credits` | 402 | Available credit balance is below credits_per_page. Purchase a credit pack or redeem a promo code at /workspace/billing. |
| `idempotency_conflict` | 409 | Same Idempotency-Key was reused with different arguments on the same agent key. Generate a fresh Idempotency-Key whenever tool arguments change. |
| `in_progress` | 409 | An identical request with this Idempotency-Key is still running. Wait for the in-flight call to complete before retrying. |
| `upstream_failed` | 502 | Upstream provider failed or returned an invalid payload. Reserved credits were released (0 credits charged). Retry with a new Idempotency-Key. |
