sFOX API
Sign InOpen Account
Connect API
Connect API
  • Introduction
    • Welcome
    • Getting Started
    • Resources
      • Terminology
      • Systems & Operations
      • Integration Options
    • Guides
      • End User Onboarding & KYC
        • Individuals
        • Businesses
        • Enhanced Due Diligence
  • REST API
    • REST Endpoints
    • Authentication
    • End Users
      • Create End User Account
      • Request Verification Code
      • Confirm Verification Code
      • Create User Auth Token(s)
      • Get End User(s)
      • Get EDD Requests
      • Get EDD Prompts
      • Create EDD Responses
        • Uploading Files as Responses
      • Submit Documents
      • Deactivate User
    • Payments
      • Create Bank Account (Plaid)
      • Create Bank Account
      • Get Bank Account
      • Get Plaid Processors
      • Amend Plaid Processors
      • Verify Bank Account
      • Delete Bank Account
      • Get Wire Instructions
      • Get ACH Agreement Status
      • Request ACH Onboarding
      • Get ACH Deposit Limit
    • Withdrawals
      • Confirm Withdrawal
      • Resend Confirmation Code
      • Cancel Withdrawal
    • Transfers
      • Create Transfer
      • Confirm Transfer
      • Resend Confirmation Code
      • Cancel Transfer
      • Get Transfer Permissions
      • Get Transfer History
    • Monetization
      • Create Setting
      • Update Setting
      • Delete Setting
      • Get Settings
      • Get Permissions
      • Get Monetization History
  • WebSocket API
    • Connecting
    • Authentication
    • Subscribing & Unsubscribing
    • Message Format
    • End Users
      • Onboarding
      • Balances
      • Orders
      • Trades
    • Market Data
      • Order Book
      • Trades
      • Ticker
  • Single Sign-On
    • Overview
      • IdP Initiated SSO
    • IdP Data
    • SAML Response Data
  • Errors
    • Error Codes
Powered by GitBook
On this page
  • Subscription Instructions
  • Payload Details
  • Example Code & Trades Message
  1. WebSocket API
  2. Market Data

Trades

Real-time tick data feed of any trade executed on sFOX’s supported liquidity venues

Subscription Instructions

Subscription Format
Example

trades.sfox.<basequote>

trades.sfox.btcusd

Payload Details

Key
Description

buyOrderId

Order ID of the buy trade

sellOrderId

Order ID of the sell trade

pair

The currency pair of this trade

price

Price of this trade

quantity

Quantity traded

side

Side taken buy or sell

exchange

Location of the trade

exchange_id

ID of the trade location

timestamp

Time of the trade

Example Code & Trades Message

const WebSocket = require('ws')

const ws = new WebSocket('wss://ws.sfox.com/ws')

ws.on('open', function() {
  const authMessage = {
   type: 'authenticate',
   apiKey: '<ENTERPRISE_API_KEY>',
   enterprise: 'true'
  }
  
  ws.send(JSON.stringify(authMessage))
})

// After successful authentication, subscribe to trades feed
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['trades.sfox.btcusd', 'trades.sfox.ethusd']
}

ws.send(JSON.stringify(subscribeMsg))
import asyncio
import json
import websockets

async def main(uri):
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "type": "authenticate",
            "apiKey": "<ENTERPRISE_API_KEY>",
            "enterprise": "true"
        }))

        # After successful authentication message, subscribe to the trades feed
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": ["trades.sfox.btcusd"]
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
{
  "sequence": 24,
  "recipient": "trades.sfox.btcusd",
  "timestamp": 1649901441593380244,
  "payload": {
    "id": "1062696823",
    "quantity": "0.005",
    "price": "41492",
    "exchange": "market1",
    "exchange_id": 2,
    "side": "buy",
    "pair": "btcusd",
    "pair_id": 1,
    "timestamp": "2022-04-14T01:57:21.521999872Z",
    "timeStamp": "2022-04-14T01:57:21.521",
    "buyOrderId": "",
    "sellOrderId": "",
    "is_decimal": true
  }
}

PreviousOrder BookNextTicker

Last updated 1 year ago