AI代理
程式與AI代理使用同一套免費API。先讀取/llms.txt,再用帳戶建立的API金鑰做Bearer認證,每個帳戶每小時可請求3,000次。
/llms.txt規格
/llms.txt是純文字Markdown規格。代理可讀取後加入模型上下文,取得API查詢方式。
bash
# Fetch the manifest curl "https://api.clarifindata.com/llms.txt" # Or in your agent's system prompt / tool setup: # GET https://api.clarifindata.com/llms.txt
/llms.txt列出資料集名稱、欄位、來源與範例查詢。可用資料以即時目錄為準;請保留回應中的attribution。
以Bearer金鑰查詢
由帳戶持有人完成註冊、電子郵件驗證並建立金鑰,再將金鑰存入代理的安全環境。不要將金鑰放進公開提示、瀏覽器程式或版本控制。
python
import os
import httpx
with httpx.Client(
base_url="https://api.clarifindata.com",
headers={"Authorization": f"Bearer {os.environ['CLARIFINDATA_API_KEY']}"},
timeout=30,
) as client:
catalog = client.get("/v1/data")
catalog.raise_for_status()
response = client.get(
"/v1/data/TaiwanStockPrice",
params={"stock_id": "2330", "limit": 5},
)
response.raise_for_status()
result = response.json()
print(result["data"])
print(result["attribution"])額度與資料顯名
代理與網頁查詢共用帳戶額度。使用GET /v1/key/info查看剩餘用量;收到429後,先暫停查詢,再以退避方式重試。
請把attribution和資料一起保存、一起轉交。資料取自公開網頁及開放資料,本服務未與資料來源機構簽約,不是官方資料。