快速入門指南 - CoinPaprika API
5 分鐘內取得加密貨幣資料:CoinPaprika API 在免費方案中無需 API 金鑰、註冊或身分驗證。
步驟 1:發出第一個請求
只需發送 HTTP GET 請求即可取得 JSON 回應。所有 API 端點皆可透過 https://api.coinpaprika.com/v1/ 存取。無需標頭或身分驗證。
程式碼範例
cURL
curl https://api.coinpaprika.com/v1/tickers/btc-bitcoinPython
import requests
response = requests.get("https://api.coinpaprika.com/v1/tickers/btc-bitcoin")
data = response.json()
price = data["quotes"]["USD"]["price"]
market_cap = data["quotes"]["USD"]["market_cap"]
volume = data["quotes"]["USD"]["volume_24h"]
print(f"Bitcoin Price: {price:,.2f}")
print(f"Market Cap: {market_cap:,.0f}")
print(f"24h Volume: {volume:,.0f}")JavaScript
const response = await fetch(
"https://api.coinpaprika.com/v1/tickers/btc-bitcoin"
);
const data = await response.json();
console.log(`Bitcoin Price: $${data.quotes.USD.price.toFixed(2)}`);
console.log(`Market Cap: $${data.quotes.USD.market_cap.toLocaleString()}`);
console.log(`24h Change: ${data.quotes.USD.percent_change_24h}%`);Go
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, _ := http.Get("https://api.coinpaprika.com/v1/tickers/btc-bitcoin")
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
quotes := data["quotes"].(map[string]interface{})
usd := quotes["USD"].(map[string]interface{})
fmt.Printf("Bitcoin Price: $%.2f\n", usd["price"])
}步驟 2:常見使用情境
取得所有行情
GET /v1/tickers傳回所有加密貨幣的價格、市值與交易量。
搜尋幣種
GET /v1/search?q=ethereum依名稱或代號搜尋幣種、交易所與人物。
取得歷史 OHLCV
GET /v1/coins/btc-bitcoin/ohlcv/historical?start=2024-01-01用於圖表與技術分析的歷史 K 線資料。
全球市場統計
GET /v1/global整個加密市場的總市值、BTC 市佔率與 24 小時交易量。
步驟 3:速率限制
| 方案 | 請求數/月 | 速率限制 |
|---|---|---|
| 免費 | 20,000 | 10 次請求/秒 |
| Pro | 無限制 | 100 次請求/秒 |