Skip to main content

RealMarketAPI Python SDK beta

Project description

RealMarketAPI Python SDK (Beta)

Official beta Python SDK for RealMarketAPI REST and WebSocket market data endpoints.

Website: https://realmarketapi.com/

Why use this SDK

  • Thin Python wrapper for RealMarketAPI HTTP and streaming APIs.
  • Simple class-based client for request/response usage.
  • Async WebSocket streams with automatic reconnect behavior.
  • Small dependency footprint (httpx, websockets).

Requirements

  • Python 3.9+
  • RealMarketAPI API key

Install

pip install realmarketapi-python-sdk-beta

Quick start

REST client

from realmarketapi_sdk import RealMarketApiClient

client = RealMarketApiClient(api_key="YOUR_API_KEY")

try:
    price = client.get_price("EURUSD", "M1")
    print("Close:", price.get("closePrice"))
finally:
    client.close()

WebSocket client

import asyncio
from realmarketapi_sdk import RealMarketApiWebSocket

ws = RealMarketApiWebSocket(api_key="YOUR_API_KEY")

async def main() -> None:
    async for tick in ws.stream_price("BTCUSDT", "M1"):
    print(tick)

asyncio.run(main())

REST API methods

All REST methods return a Python dict parsed from JSON and include your API key as query parameter.

get_price(symbol_code, time_frame)

Example:

price = client.get_price("EURUSD", "M1")

Example response payload:

{
    "symbolCode": "EURUSD",
    "timeFrame": "M1",
    "openPrice": 1.07874,
    "highPrice": 1.07882,
    "lowPrice": 1.07868,
    "closePrice": 1.07879,
    "openTime": "2026-05-21T09:12:00Z"
}

get_candles(symbol_code, time_frame)

Example:

candles = client.get_candles("BTCUSDT", "M5")

Example response payload:

{
    "symbolCode": "BTCUSDT",
    "timeFrame": "M5",
    "candles": [
        {
            "openTime": "2026-05-21T09:10:00Z",
            "openPrice": 68620.3,
            "highPrice": 68690.1,
            "lowPrice": 68588.7,
            "closePrice": 68655.8,
            "volume": 128.42
        }
    ]
}

get_history(symbol_code, start_time, end_time, page_number=1, page_size=20)

Example:

history = client.get_history(
    symbol_code="EURUSD",
    start_time="2026-05-20T00:00:00Z",
    end_time="2026-05-21T00:00:00Z",
    page_number=1,
    page_size=20,
)

Example response payload:

{
    "pageNumber": 1,
    "pageSize": 20,
    "totalPages": 14,
    "items": [
        {
            "openTime": "2026-05-20T00:00:00Z",
            "openPrice": 1.07913,
            "highPrice": 1.07942,
            "lowPrice": 1.07898,
            "closePrice": 1.07920,
            "volume": 241.11
        }
    ]
}

get_symbols()

Example:

symbols = client.get_symbols()

Example response payload:

{
    "symbols": ["EURUSD", "BTCUSDT", "XAUUSD"]
}

get_sma(symbol_code, time_frame, period=20)

Example:

sma = client.get_sma("EURUSD", "M15", period=50)

Example response payload:

{
    "symbolCode": "EURUSD",
    "timeFrame": "M15",
    "period": 50,
    "value": 1.08024,
    "openTime": "2026-05-21T09:00:00Z"
}

WebSocket streaming methods

The WebSocket client exposes async generators and reconnects after transient failures.

stream_price(symbol_code, time_frame)

Example:

async for event in ws.stream_price("EURUSD", "M1"):
    print(event)

Example message payload:

{
    "symbolCode": "EURUSD",
    "timeFrame": "M1",
    "closePrice": 1.07879,
    "openTime": "2026-05-21T09:12:00Z"
}

stream_candles(symbol_code, time_frame)

Example:

async for event in ws.stream_candles("BTCUSDT", "M5"):
    print(event)

Example message payload:

{
    "symbolCode": "BTCUSDT",
    "timeFrame": "M5",
    "openTime": "2026-05-21T09:10:00Z",
    "openPrice": 68620.3,
    "highPrice": 68690.1,
    "lowPrice": 68588.7,
    "closePrice": 68655.8,
    "volume": 128.42
}

Error handling notes

  • REST methods call response.raise_for_status(), so HTTP 4xx/5xx responses raise httpx.HTTPStatusError.
  • WebSocket streams retry on connection errors using reconnect_delay_seconds (default 2.0).
  • Cancel the async task to stop streaming cleanly.

Beta scope and compatibility

  • Current REST coverage: price, candles, history, symbols, SMA.
  • Current WebSocket coverage: price and candles.
  • This package is beta and may receive additive changes before stable 1.0.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

realmarketapi_python_sdk_beta-0.1.0b1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file realmarketapi_python_sdk_beta-0.1.0b1.tar.gz.

File metadata

File hashes

Hashes for realmarketapi_python_sdk_beta-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 b36a78ff0a8a8a34a9ee83a452a0ed605065b225f8c7f2efc3ad3a8967e44a69
MD5 938049b24c8c740cc60ef99fe8accd79
BLAKE2b-256 db05a18ba542e4799130a990349c0249b2828b3e7596d26ab3d510fa62d2ea68

See more details on using hashes here.

File details

Details for the file realmarketapi_python_sdk_beta-0.1.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for realmarketapi_python_sdk_beta-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 95ef5b5878f702bec81415291912c715f694e4b41d6be6eb1759639f327582ff
MD5 e0184cf9e2af9f141c5ffa24431e108f
BLAKE2b-256 ac6d918d94a4b2739e23a7175fb29ae103395cd9957c6609bedb54bed6ed397a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page