Trading APIs, FIX and WebSocketsAPI

An API (application programming interface) lets software place orders and receive data from a broker or exchange. FIX is the long-standing industry protocol for electronic trading messages; WebSocket feeds stream live prices over a persistent connection. APIs usually have rate limits on how many requests you can send.

Most trading today runs through software. APIs let programs send orders and read data, FIX is the industry's standard message language, and WebSockets stream live prices. Each comes with limits and risks that a trader using code needs to understand.

Category
Trading Strategies
Reading time
4 min
Also called
Trading API, FIX protocol, WebSocket feed
Updated

Trading technology in plain words

Automated systems that accidentally swamp an exchange's matching engine with messages are one known cause of disruption in electronic markets.1

FIX is a global open standard that lets financial firms exchange trading information quickly, accurately and securely.2

WebSocket is a protocol for two-way communication between a client, such as a browser page, and a remote server that has agreed to talk to it.3

How software trades through an API

  1. Get API keys

    Create keys with the broker and limit their permissions.

  2. Connect to data

    Use a WebSocket instead of repeatedly polling over HTTP when you need a live two-way connection.3

  3. Send orders

    Place a Limit Order or Market Order through the order endpoint or a FIX session.

  4. Respect rate limits

    Respect rate limits — on Kraken, once an API key's call counter passes its maximum, further calls are throttled.4

  5. Add controls

    Add controls such as pre-trade caps on order size, price bands around the market, message throttles and daily price limits.1

  6. Check local rules

    Rules for automated and API trading differ by country and by venue.

Worked examples

Example 1 — Streaming prices

Faster data

A hypothetical bot uses a WebSocket feed instead of asking for prices every second.

Example 1 — Streaming prices — calculation
Requests savedMost
FillsOn time

A WebSocket provides an alternative to HTTP polling, so the bot reacts sooner with fewer calls.3

Example 2 — Rate limited

Blocked

A hypothetical script sends too many requests and is blocked mid-trade.

Example 2 — Rate limited — calculation
CallsFar above limit
Missed exit−1.5R

Hitting the rate limit blocks further calls for a few seconds — longer if calls keep coming — so the exit order never went through.4

Example 3 — Shared language

Quick link

A hypothetical fund links to a new broker over FIX in days rather than months.

Example 3 — Shared language — calculation
Custom codeLittle
Setup timeShort

FIX acts as a shared language, so banks, asset managers, exchanges and vendors can connect without building a custom link for every counterparty.2

REST API vs WebSocket vs FIX

AspectREST APIWebSocket / FIX
ConnectionOne request at a timePersistent session
Best forOrders and account dataLive prices and fast order flow
UsersRetail and prosMostly pros for FIX
Main limitRate limitsSession and throttle limits

Where trading technology is used

Advantages and disadvantages

Advantages

  • Faster and more consistent than clicking.
  • Live data without constant polling.
  • FIX avoids custom links per firm.
  • Enables automated risk controls.

Disadvantages

  • Coding errors can be costly.
  • Rate limits can block orders.
  • Connections can drop.
  • Keys must be kept secure.

Going deeper

Read as far as you need. Each level builds on the one before it.

What FIX is

Beginner

FIX is an open, global messaging standard built for fast, accurate and secure exchange of trading data between institutions.2

Streaming

Intermediate

A WebSocket keeps one connection open in both directions between a client and a server that has agreed to it, which suits streaming prices.3

Risk controls

Advanced

Typical exchange controls include order-size caps, price collars, message throttles and daily price limits; the rules differ by country.1

Common mistakes

  1. Ignoring rate limits

    Blocked calls can stop exits.

  2. Giving keys withdrawal rights

    Limit permissions to trading.

  3. No reconnect logic

    Dropped feeds mean stale prices.

  4. Testing live first

    Use a demo or sandbox.

Check your understanding

Test yourself before moving on. Each answer comes with an explanation.

Q1What does a WebSocket replace?
Q2What happens when an API counter exceeds its maximum?

Key points to remember

  1. APIs let software trade and read data.
  2. FIX is the industry message standard.
  3. WebSockets stream live data.
  4. Rate limits can block calls.
  5. Rules differ by country.

Frequently asked questions

Do I need FIX as a retail trader?

Usually not; most retail APIs use REST and WebSockets.

Are API keys risky?

They can be; limit permissions and store them safely.

Why was my bot blocked?

It likely hit a rate limit.

Further learning

Sources

This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.

  1. CFTC. Electronic Trading Risk Principles (Final Rule, 85 FR 2020-27622) (opens in a new tab) Checked .
  2. FIX Trading Community. The FIX Protocol (opens in a new tab) Checked .
  3. IETF. RFC 6455: The WebSocket Protocol (opens in a new tab) Checked .
  4. Kraken. Spot REST Rate Limits (opens in a new tab) Checked .

Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.