## 🚀 OneKey Gateway API Registry Easily register, route, track, and monetize your APIs with OneKey Gateway. Convert your API to CLIs, Skills and more. This guide walks you through: A quick example using + How to register your API How to call it via OneKey Gateway (REST + CLI) Full JSON/YAML configuration examples Secure Authentication, support header API keys `AUTH_HEADER`, `Bearer Token`, etc. ### Quickstart 1. Your Original API Assume you already have an API: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H ": $YOUR_API_KEY" \ -d '' ``` **Example** ```shell export FINANCE_AGENT_API_KEY=your_finance_agent_key curl -X POST https://aiagenta2z.aiagenta2z.com/financeagent/api/v1/get_hk_stock_market_hkex \ -H "Content-Type: application/json" \ -H "X-Finance-Key: $FINANCE_AGENT_API_KEY" \ -d '{"symbol_list": ["700", "1024"]}' ``` 2. Describe Your API (Meta) | Field | Example | Description | | ----------- |----------------------------| --------------------- | | api_id | `get_hk_stock_market_hkex` | Unique API identifier | | protocol | `http`, `mcp`, `rpc` | Default is `http` | | endpoint | `` | Your API URL | | method | `POST` | GET / POST | | params | `` | Request body or query | | auth.type | `API_KEY` | Auth type | | auth.header | `X-Finance-Key` | Header name | | auth.value | `$YOUR_API_KEY` | Your API key | 3. Register Your API Create a config file: ```shell agent.json # OR agent.yaml ``` Upload API and Agent meta using CLI `agtm`: Get the registry [Agent Marketplace Keys](https://deepnlp.org/workspace/keys). ``` ## Get your Onw Registry Keys export AI_AGENT_MARKETPLACE_ACCESS_KEY="TEST_KEY_AI_AGENT_REGISTRY" agtm upload --config ./agent.json # or agtm upload --config ./agent.yaml ``` 4. Call via OneKey Gateway After registration, you can start to use onekey gateway to authenticate and start to track your API usage and routed by agent APIs and command lines CLI. **REST API Usage** Get the onekey-gateway keys DEEPNLP_ONEKEY_ROUTER_ACCESS [Keys](https://deepnlp.org/workspace/keys). ```shell export DEEPNLP_ONEKEY_ROUTER_ACCESS=your_access_key curl -X POST "https://agent.deepnlp.org/agent_router" \ -H "Content-Type: application/json" \ -H "X-OneKey: $DEEPNLP_ONEKEY_ROUTER_ACCESS" \ -d '{ "unique_id": "aiagenta2z/financeagent", "api_id": "get_hk_stock_market_hkex", "data": { "symbol_list": ["700", "1024"] } }' ``` **CLI Usage of Your Registered API** ```shell npx onekey agent aiagenta2z/financeagent get_hk_stock_market_hkex '{"symbol_list": ["700", "1024"]}' ``` 🧱 API Meta Schema #### Parameters | KEY | Type | Description | |-------------|------|-----------------------------------------------------| | api_list | List | List of API Information | | api_id | str | The unique Id to identifiy each API | | protocol | str | `http`,`mcp`,`rpc` Default to `http` for API Calling | | description | str | Description Usage | | endpoint | str | endpoint URL | | method | str | GET/POST | | params | Dict | Parameters | | auth | Dict | The authentication method of the API | #### Auth Fields | KEY | Type | Description | |-------------|------|-----------------------------------------------------| | auth.type | str | `API_KEY`, `BEAR_TOKEN` | | auth.header | str | Headers Key header | | auth.value | str | Headers Value header | 📦 Full Example (JSON) #### Json `agent.json` file contents ```shell { "publisher_id": "finance-agent", "name": "Finance Agent", "content": "The Finance Agent to get stock information from global stock market", "website": "https://www.my_first_agent.com", "field": "AI AGENT", "subfield": "Finance", "content_tag_list": "coding,python", "github": "https://github.com/aiagenta2z/FinanceAgent", "thumbnail_picture": "https://avatars.githubusercontent.com/u/242328252?s=200&v=4", "upload_image_files": "", "price_type": "PER_CALL", "price_per_call_credit": 10.0, "price_fixed_credit": 0.0, "price_subscription": "Basic: your basic plan introduction, Advanced: Your Advanced Plan introduction, etc.", "api_list": [ { "api_id": "get_us_stock_market", "protocol": "http", "description": "Get US stock Market data", "endpoint": "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_us_stock_market", "method": "GET", "params": { "symbol_list": "array[string]", }, "auth": { "type": "API_KEY", "header": "X-API-Key", "value": "REGISTRY_API_GET_KEY" } }, { "api_id": "get_hk_stock_market", "protocol": "http", "description": "Get Hong Kong stock market data", "endpoint": "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_hk_stock_market", "method": "GET", "params": { "symbol_list": "array[string]", "market": "string=HK" }, "auth": { "type": "API_KEY", "header": "X-API-Key", "value": "REGISTRY_API_GET_KEY" } }, { "api_id": "get_cn_stock_market", "protocol": "http", "description": "Get China stock market data", "endpoint": "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_cn_stock_market", "method": "GET", "auth": { "type": "API_KEY", "header": "X-API-Key", "value": "REGISTRY_API_GET_KEY" } }, { "api_id": "get_uk_stock_market", "protocol": "http", "description": "Get UK stock market data", "endpoint": "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_uk_stock_market", "method": "GET", "auth": { "type": "API_KEY", "header": "X-API-Key", "value": "REGISTRY_API_GET_KEY" } }, { "api_id": "get_india_stock_market", "protocol": "http", "description": "Get India stock market data", "endpoint": "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_india_stock_market", "method": "GET", "auth": { "type": "API_KEY", "header": "X-API-Key", "value": "REGISTRY_API_GET_KEY" } } ] } ``` #### yaml `agent.yaml` file contents ```yaml publisher_id: "finance-agent" name: "Finance Agent" content: "The Finance Agent to get stock information from global stock market" website: "https://www.my_first_agent.com" field: "AI AGENT" subfield: "Finance" content_tag_list: "coding,python" github: "https://github.com/aiagenta2z/FinanceAgent" thumbnail_picture: "https://avatars.githubusercontent.com/u/242328252?s=200&v=4" upload_image_files: "" price_type: "PER_CALL" price_per_call_credit: 10.0 price_fixed_credit: 0.0 price_subscription: "Basic: your basic plan introduction, Advanced: Your Advanced Plan introduction, etc." api_list: - api_id: "get_us_stock_market" description: "Get US stock Market data" endpoint: "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_us_stock_market" protocol: "http" method: "GET" params: symbol_list: "array[string]" market: "string=US" auth: type: "API_KEY" header: "X-API-Key" value: "REGISTRY_API_GET_KEY" - api_id: "get_hk_stock_market" description: "Get Hong Kong stock market data" endpoint: "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_hk_stock_market" protocol: "http" method: "GET" params: symbol_list: "array[string]" market: "string=HK" auth: type: "API_KEY" header: "X-API-Key" value: "REGISTRY_API_GET_KEY" - api_id: "get_cn_stock_market" description: "Get China stock market data" endpoint: "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_cn_stock_market" protocol: "http" method: "GET" auth: type: "API_KEY" header: "X-API-Key" value: "REGISTRY_API_GET_KEY" - api_id: "get_uk_stock_market" description: "Get UK stock market data" endpoint: "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_uk_stock_market" protocol: "http" method: "GET" auth: type: "API_KEY" header: "X-API-Key" value: "REGISTRY_API_GET_KEY" - api_id: "get_india_stock_market" description: "Get India stock market data" endpoint: "https://financeagent.aiagenta2z.com/financeagent/v1/api/get_india_stock_market" protocol: "http" method: "GET" auth: type: "API_KEY" header: "X-API-Key" value: "REGISTRY_API_GET_KEY" ``` 🔁 Request Flow (Mental Model) ```shell User / CLI ↓ OneKey Gateway ↓ Your Registered API ↓ Response returned + usage tracked + credits deducted ``` 🎯 Summary With just `api_endpoint`, `data`, `auth`, etc. You can: Register your API Route via OneKey Gateway Enable CLI + agent usage Track + monetize automatically