sFOX API
Sign InOpen Account
sFOX API
sFOX API
  • Introduction
    • Welcome
    • Getting Started
    • Systems & Operations
    • Rate Limits
  • REST API
    • REST Endpoints
    • Authentication
    • Rate Limits
    • Account Management
      • Get All Balances
      • Get All Currencies
      • Get All Currency Pairs
      • Get All Transactions
      • Get Fees
    • Orders
      • Order Types
      • Create Order
      • Cancel Order
      • Cancel Multiple Orders
      • Cancel All Orders
      • Amend Order
      • Get Single Order
      • Get All Open Orders
      • Get All Done Orders
      • Get All Trades
    • Request for Quote (RFQ)
    • Post-Trade Settlement (PTS)
      • Get Account Risk Metrics
      • Get All Positions
      • Get All Funding Transactions
      • Get All Funding Rates
      • Get All Risk Modes
      • Create Transfer
    • Shorting
      • Get Account Risk Metrics
      • Get All Positions
    • Transfers
      • Get All Deposit Addresses
      • Get Single Deposit Address
      • Create Deposit Address
      • Deposit From Bank Account
      • Withdraw From Account
      • Get Single Withdrawal Fee
      • Create Transfer
    • Custody (sFOX SAFE)
      • Get Whitelisted Addresses
      • Add Whitelisted Address
      • Delete Whitelisted Address
      • Get Approval Rules
      • Create Approval Rule
      • Edit Approval Rule
      • Get Approval Requests
      • Respond to Approval Request
    • Staking
      • Get Staking Currencies
      • Get All Staking Transactions
      • Create Stake
      • Cancel Stake
      • Unstake
    • Market Data
      • Get Candlesticks
      • Get Volume Analytics
      • Get Order Estimate
      • Get Order Book
    • Reporting
      • Get Orders Report
      • Get Monthly Summary
      • Get Portfolio Valuation
      • Get All Transactions
  • WebSocket API
    • Introduction
    • Connecting
    • Rate Limits
    • Authentication
    • Subscribing & Unsubscribing
    • Message Format
    • Market Data
      • Order Book
      • Trades
      • Ticker
    • Orders & Account Data
      • Orders
      • Trades
      • Balances
      • Post-Trade Settlement
  • FIX API
    • FIX Order Entry
    • FIX Market Data
    • QuickFIX Guide
  • Errors
    • Error Codes
Powered by GitBook
  1. REST API
  2. Market Data

Get Candlesticks

GET https://chartdata.sfox.com/candlesticks

Retrieve historical candlestick / OHLCV (Open-High-Low-Close-Volume) data for a currency pair. Returns an array of objects, each representing a candle.

  • Data represents aggregated trades data from all of sFOX's supported liquidity providers. NOT representative of trades executed on sFOX.

  • Data is not forward-filled and, therefore, may be incomplete. e.g. no data will be returned for an interval during which 0 trades were recorded.

Responses are limited to 500 candles. If the requested startTime , endTime , and period will result in more than 500 data points, your request will be rejected. To retrieve data over a larger time range, you will need to make multiple requests with new startTime / endTime ranges. Candles may precede your specified startTime value.

Query Parameters

Parameter
Type
Description

pair required

string

Specify the currency pair to retrieve data for. e.g. btcusd

startTime required

timestamp

The unix timestamp (seconds) of the first datapoint returned

endTime required

timestamp

The unix timestamp (seconds) of the last datapoint you want returned

period

int

The duration or interval of each datapoint or candle in seconds (e.g. period = 60 would return 1-minute candles). Possible values:

  • 60 (1 minute) default if not specified

  • 300 (5 minute)

  • 900 (15 minute)

  • 3600 (1 hour)

  • 21600 (6 hour)

  • 86400 (1 day)

Response Body

Key
Description

open_price

The price of the first trade recorded after the start_time

high_price

The highest trade price during this period

low_price

The lowest trade price during this period

close_price

The price of the last trade executed in this period

volume

Total base currency volume traded during this period

start_time

The unix timestamp of the beginning of the period

pair

The trading pair / symbol

candle_period

The duration of each datapoint in seconds

vwap

The volume-weighted average price of the period

trades

The total number of trades executed across all liquidity providers during that period

Responses

200
[
  {
    "open_price":"9654",
    "high_price":"9662.37",
    "low_price":"9653.66",
    "close_price":"9655.73",
    "volume":"6.31945755",
    "start_time":1592939280,
    "pair":"btcusd",
    "candle_period":60,
    "vwap":"9655.70504211",
    "trades":53
  }
]

Example Request

curl 'https://chartdata.sfox.com/candlesticks?endTime=1665165809&pair=btcusd&period=86400&startTime=1657217002'
const axios = require('axios');

axios({
  method: 'get',
  url: 'https://chartdata.sfox.com/candlesticks',
  params: {
    pair: 'btcusd',
    startTime: 1657217002,
    endTime: 1665165809,
    period: 86400
  }
}).then(response => {
  console.log(response)
}).catch(err => {
  console.error(err)
});
import requests

data = requests.get(
  "https://chartdata.sfox.com/candlesticks",
  headers={
    "Authorization": "Bearer <API_KEY>",
  },
  params={
   "pair":"btcusd",
   "startTime": 1657217002,
   "endTime": 1665165809,
   "period": 86400
  }
)
print(data)
PreviousMarket DataNextGet Volume Analytics

Last updated 1 year ago