|
| 1 | +--- |
| 2 | +sidebar_position: 5 |
| 3 | +--- |
| 4 | +import Tabs from '@theme/Tabs'; |
| 5 | +import TabItem from '@theme/TabItem'; |
| 6 | +import CodeBlock from '@theme/CodeBlock'; |
| 7 | +import ApiCallExample from '@site/src/components/ApiCallExample'; |
| 8 | + |
| 9 | +# Get CAT Price |
| 10 | + |
| 11 | +This endpoint allows you to fetch real-time price information for Chia Asset Tokens (CATs) in various currencies. Track current market prices, exchange rates, and fiat valuations for any CAT in the Chia ecosystem. This data is essential for portfolio tracking, trading decisions, and financial applications built on the Chia blockchain. |
| 12 | + |
| 13 | +### Endpoint |
| 14 | + |
| 15 | +<Tabs> |
| 16 | + <TabItem value="mainnet" label="Mainnet"> |
| 17 | + |
| 18 | +``` |
| 19 | +GET https://api.spacescan.io/cat/catprice/{asset_id}?currency={currency_code} |
| 20 | +``` |
| 21 | + |
| 22 | + </TabItem> |
| 23 | + <TabItem value="testnet" label="Testnet"> |
| 24 | + |
| 25 | +``` |
| 26 | +GET https://api-testnet11.spacescan.io/cat/catprice/{asset_id}?currency={currency_code} |
| 27 | +``` |
| 28 | + |
| 29 | + </TabItem> |
| 30 | +</Tabs> |
| 31 | + |
| 32 | +### Parameters |
| 33 | + |
| 34 | +| Parameter | Type | Description | Required | |
| 35 | +|--------------|--------|-------------------------------------------------|----------| |
| 36 | +| asset_id | string | The unique identifier (TAIL hash) of the CAT | Yes | |
| 37 | +| currency | string | Currency code (e.g., USD, EUR, INR, etc.) | No | |
| 38 | + |
| 39 | +:::info Free API |
| 40 | +Use `api.spacescan.io` for free tier access. See our [API Plans](https://spacescan.io/apis#plans) for rate limits and features. |
| 41 | +::: |
| 42 | + |
| 43 | +:::tip Pro API |
| 44 | +Use `pro-api.spacescan.io` with your API key in the `x-api-key` header. See our [API Plans](https://spacescan.io/apis#plans) for details. |
| 45 | + |
| 46 | +```bash |
| 47 | +curl -X GET "https://pro-api.spacescan.io/cat/catprice/{asset_id}?currency=INR" \ |
| 48 | + -H "x-api-key: YOUR_API_KEY" |
| 49 | +``` |
| 50 | +::: |
| 51 | + |
| 52 | +### Live API Test |
| 53 | + |
| 54 | +<Tabs> |
| 55 | + <TabItem value="mainnet" label="Mainnet"> |
| 56 | + <a href="https://api.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" target="_blank" rel="noopener noreferrer" className="api-test-button"> |
| 57 | + 🚀 Test API in Browser |
| 58 | + </a> |
| 59 | + </TabItem> |
| 60 | + <TabItem value="testnet" label="Testnet"> |
| 61 | + <a href="https://api-testnet11.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" target="_blank" rel="noopener noreferrer" className="api-test-button"> |
| 62 | + 🚀 Test API in Browser |
| 63 | + </a> |
| 64 | + </TabItem> |
| 65 | +</Tabs> |
| 66 | + |
| 67 | +### Request Example |
| 68 | + |
| 69 | +<Tabs> |
| 70 | + <TabItem value="curl" label="cURL"> |
| 71 | + <Tabs> |
| 72 | + <TabItem value="mainnet" label="Mainnet"> |
| 73 | + <CodeBlock language="bash"> |
| 74 | + curl -X GET "https://api.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" |
| 75 | + </CodeBlock> |
| 76 | + </TabItem> |
| 77 | + <TabItem value="testnet" label="Testnet"> |
| 78 | + <CodeBlock language="bash"> |
| 79 | + curl -X GET "https://api-testnet11.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" |
| 80 | + </CodeBlock> |
| 81 | + </TabItem> |
| 82 | + </Tabs> |
| 83 | + </TabItem> |
| 84 | + <TabItem value="python" label="Python"> |
| 85 | + <Tabs> |
| 86 | + <TabItem value="mainnet" label="Mainnet"> |
| 87 | + <CodeBlock language="python"> |
| 88 | + import requests |
| 89 | + |
| 90 | + asset_id = "db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20" |
| 91 | + currency = "INR" |
| 92 | + url = f"https://api.spacescan.io/cat/catprice/{asset_id}?currency={currency}" |
| 93 | + |
| 94 | + response = requests.get(url) |
| 95 | + data = response.json() |
| 96 | + print(data) |
| 97 | + </CodeBlock> |
| 98 | + </TabItem> |
| 99 | + <TabItem value="testnet" label="Testnet"> |
| 100 | + <CodeBlock language="python"> |
| 101 | + import requests |
| 102 | + |
| 103 | + asset_id = "db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20" |
| 104 | + currency = "INR" |
| 105 | + url = f"https://api-testnet11.spacescan.io/cat/catprice/{asset_id}?currency={currency}" |
| 106 | + |
| 107 | + response = requests.get(url) |
| 108 | + data = response.json() |
| 109 | + print(data) |
| 110 | + </CodeBlock> |
| 111 | + </TabItem> |
| 112 | + </Tabs> |
| 113 | + </TabItem> |
| 114 | + <TabItem value="javascript" label="JavaScript"> |
| 115 | + <Tabs> |
| 116 | + <TabItem value="mainnet" label="Mainnet"> |
| 117 | + <CodeBlock language="javascript"> |
| 118 | + const assetId = "db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20"; |
| 119 | + const currency = "INR"; |
| 120 | + const url = `https://api.spacescan.io/cat/catprice/${assetId}?currency=${currency}`; |
| 121 | + |
| 122 | + fetch(url) |
| 123 | + .then(response => response.json()) |
| 124 | + .then(data => console.log(data)) |
| 125 | + .catch(error => console.error('Error:', error)); |
| 126 | + </CodeBlock> |
| 127 | + </TabItem> |
| 128 | + <TabItem value="testnet" label="Testnet"> |
| 129 | + <CodeBlock language="javascript"> |
| 130 | + const assetId = "db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20"; |
| 131 | + const currency = "INR"; |
| 132 | + const url = `https://api-testnet11.spacescan.io/cat/catprice/${assetId}?currency=${currency}`; |
| 133 | + |
| 134 | + fetch(url) |
| 135 | + .then(response => response.json()) |
| 136 | + .then(data => console.log(data)) |
| 137 | + .catch(error => console.error('Error:', error)); |
| 138 | + </CodeBlock> |
| 139 | + </TabItem> |
| 140 | + </Tabs> |
| 141 | + </TabItem> |
| 142 | +</Tabs> |
| 143 | + |
| 144 | +### Response |
| 145 | + |
| 146 | +<Tabs> |
| 147 | + <TabItem value="mainnet" label="Mainnet"> |
| 148 | + <ApiCallExample endpoint="https://api.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" /> |
| 149 | + </TabItem> |
| 150 | + <TabItem value="testnet" label="Testnet"> |
| 151 | + <ApiCallExample endpoint="https://api-testnet11.spacescan.io/cat/catprice/db1a9020d48d9d4ad22631b66ab4b9ebd3637ef7758ad38881348c5d24c38f20?currency=INR" /> |
| 152 | + </TabItem> |
| 153 | +</Tabs> |
| 154 | + |
| 155 | +### Response Schema |
| 156 | + |
| 157 | +| Field | Type | Description | |
| 158 | +|--------------|---------|-------------------------------------------------------| |
| 159 | +| status | string | The status of the API request | |
| 160 | +| amount_price | number | Current price in the requested currency | |
| 161 | +| xch_price | string | Current price in XCH | |
| 162 | + |
| 163 | +### Error Responses |
| 164 | + |
| 165 | +| HTTP Status Code | Meaning | |
| 166 | +|------------------|-------------------------------------------------------------------------------------------| |
| 167 | +| 400 | Bad Request -- Your request is invalid or unsupported currency. | |
| 168 | +| 404 | Not Found -- The specified CAT could not be found. | |
| 169 | +| 429 | Too Many Requests -- You're requesting too many times! Slow down! | |
| 170 | +| 500 | Internal Server Error -- We had a problem with our server. Try again later. | |
| 171 | +| 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. | |
0 commit comments