توسعه‌دهندگان

هر آنچه برای یکپارچه‌سازی قیمت‌های لحظه‌ای و تاریخی لازم است: مرجع تعاملی، SDK برای Python و JavaScript، مشخصات OpenAPI و یک مجموعه Postman.

شروع سریع

Python

# one file, standard library only (Python 3.9+)
curl -O https://app.marketapi.app/sdk/marketapi.py
pip install websockets          # only if you use the live stream

from marketapi import MarketAPI
api = MarketAPI("YOUR_API_KEY")
print(api.latest(["EURUSD", "XAUUSD"]))

JavaScript

// one ES module, no dependencies (Node 18+ and browsers)
curl -O https://app.marketapi.app/sdk/marketapi.mjs
npm install ws                  # only for the live stream in Node.js

import { MarketAPI } from "./marketapi.mjs";
const api = new MarketAPI({ apiKey: process.env.API_KEY });
console.log(await api.latest(["EURUSD"]));

کلاینت‌ها فایل‌های تکی هستند که در پروژه خود نگه می‌دارید، پس چیزی برای نصب از مخزن بسته‌ها و کد شخص ثالثی برای اعتماد وجود ندارد. فایل را کنار اسکریپت یا در هر پوشه‌ای از مسیر import قرار دهید.

در حال ساخت قرارداد هوشمند هستید؟

اوراکل قیمت روی زنجیره همین قیمت‌ها را به‌صورت گزارش‌های امضاشده‌ای به قرارداد شما می‌دهد که می‌تواند روی زنجیره تأییدشان کند: GET https://api.marketapi.app/v1/oracle/report?symbols=XAUUSD&chain_id=10، سپس submit(report, signature) و getPriceNoOlderThan(feedId, maxAge). مثال‌های Solidity و ethers v6، نشانی قراردادها و شناسه فیدها در مستندات اوراکل آمده است.

مرجع تعاملی

General

GET /v1/status Service status

نیازی به کلید API نیست · صورت‌حساب: free

GET /v1/openapi.json This API description (OpenAPI 3.1)

نیازی به کلید API نیست · صورت‌حساب: free

GET /v1/postman.json Postman collection

نیازی به کلید API نیست · صورت‌حساب: free

GET /v1/account Your balance, plan and limits

هر کلید API معتبر · صورت‌حساب: free

GET /v1/cost-preview Credits a request would cost

هر کلید API معتبر · صورت‌حساب: free

Symbols

GET /v1/symbols Search the symbol list

دامنه read:symbols · صورت‌حساب: free

GET /v1/symbols/{canonical} One symbol's specification

دامنه read:metadata · صورت‌حساب: free

GET /v1/symbols/{canonical}/properties/history Specification change history

دامنه read:metadata · صورت‌حساب: free

Prices

GET /v1/market-status Market status per symbol

دامنه read:latest · صورت‌حساب: free

GET /v1/prices/latest Latest bid/ask

دامنه read:latest · صورت‌حساب: 1 credit per symbol returned

History

GET /v1/bars Historical OHLC candles

دامنه read:ohlcv · صورت‌حساب: credits per block of rows

GET /v1/ticks Historical ticks

دامنه read:history · صورت‌حساب: credits per block of rows

Analytics

GET /v1/patterns/stats Pattern strategy statistics

دامنه read:metadata · صورت‌حساب: 25 credits per call

Free tier

GET /v1/free/prices/latest Delayed prices, no key

نیازی به کلید API نیست · صورت‌حساب: free (fair-use limits)

GET /v1/free/symbols Free-tier symbol list, no key

نیازی به کلید API نیست · صورت‌حساب: free (fair-use limits)

GET /v1/free/market-status Market status, no key

نیازی به کلید API نیست · صورت‌حساب: free (fair-use limits)

Oracle

GET /v1/oracle/feeds Oracle feeds, networks and signer (when the oracle is enabled)

نیازی به کلید API نیست · صورت‌حساب: free

GET /v1/oracle/catalog Oracle feeds by network: asset name, category, contract, decimals (when enabled)

نیازی به کلید API نیست · صورت‌حساب: free

GET /v1/oracle/report Signed EIP-712 price reports (when the oracle is enabled)

دامنه read:oracle · صورت‌حساب: credits per signed report

خطاها

خطاها از جزئیات مسئله RFC 9457 استفاده می‌کنند: {"type", "title", "status", "code", "detail", "request_id"}. هنگام تماس با پشتیبانی request_id را ذکر کنید.

HTTPکدمعناچه باید کرد
400invalid_parameterA parameter is missing or malformed.Check the parameter named in detail.
400too_many_symbolsToo many symbols in one request.Split the request (up to 100 symbols).
400range_too_largeThe time range is too long for this endpoint.Request shorter ranges and page.
400credentials_in_queryThe API key was sent in the URL.Send it in the Authorization header.
401unauthenticatedNo or an invalid API key.Send Authorization: Bearer <key>.
401key_revokedThe API key was revoked.Create a new key in the dashboard.
401key_expiredThe API key has expired.Create a new key or extend it.
402insufficient_balanceNo credits left.Top up or choose a plan.
402plan_credits_used_upThe plan's credits for this month are used up (your balance is never used while a plan runs).Add credits to the month or upgrade on the billing page.
402plan_endedThe API plan has ended; the balance is not used until you choose.Renew, pick a plan, or choose pay as you go on the billing page.
403insufficient_scopeThe key lacks the scope this endpoint needs.Create a key with that scope.
403ip_not_allowedThe request came from an IP the key does not allow.Update the key's IP list.
403account_inactiveThe account is suspended or not verified.Verify your email or contact support.
403sandbox_not_billableTest keys cannot call billable endpoints.Use a live key.
404not_foundResource not available.Check the URL; some features may be switched off.
404unknown_symbolThe symbol does not exist.Search /symbols or the ticker list.
404free_tier_disabledThe free tier is switched off.Use an API key.
405method_not_allowedWrong HTTP method.Use GET.
409idempotency_mismatchSame Idempotency-Key reused with different parameters.Use a new key.
409idempotency_key_usedThe Idempotency-Key was used and its answer is no longer kept (24 h, 2 MB).Send a new key for current data.
429rate_limitedToo many requests per minute or hour.Wait for Retry-After; batch symbols.
429too_many_concurrent_requestsToo many requests in parallel.Limit concurrency.
429daily_limitFree-tier daily limit reached.Retry tomorrow or use an API key.
503oracle_unavailableThe oracle signing service is temporarily unavailable.Retry with back-off.
503free_tier_unavailableThe free tier is temporarily unavailable.Retry later.
503free_tier_busyThe free tier is busy.Retry later or use an API key.