> ## Documentation Index
> Fetch the complete documentation index at: https://tradewatch.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# REST vs WebSocket API

> Compare REST and WebSocket APIs for financial data. REST for on-demand queries; WebSocket for real-time streaming of forex, crypto, and stock prices.

This page will help you understand the two main protocols available for accessing financial data through TradeWatch: [HTTP (REST API)](/api-reference/introduction) and [WebSocket API](/websocket-api/introduction). We will explain the differences between these APIs and guide you in choosing the appropriate one for your specific needs.

## Protocols Overview

|         | HTTP (Rest API)                                                                                                                                                          | WebSocket (Real-time data)                                                                                                                                                                                                                                 |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Purpose | Ideal for on-demand queries, especially when specific data is required.                                                                                                  | Designed for long-lived connections that demand real-time updates.                                                                                                                                                                                         |
| Usage   | Suitable for fetching the latest financial instrument price or making a parameterized call, like acquiring historical data or converting from one instrument to another. | By connecting to the WebSocket protocol and providing a list of symbols to monitor, the server establishes an active connection. When there is a price change for the specified instruments, the server pushes a message to notify the client immediately. |

## Choosing the Right Protocol

|             | HTTP (Rest API)                                            | WebSocket (Real-time data)                                                                                                  |
| ----------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| When to Use | If your application necessitates on-demand data queries.   | If your application requires continuous real-time updates for specific instruments.                                         |
| Usage       | Quick responses, ideal for occasional or one-off requests. | Always-on connection, instant notifications on price changes, optimized for monitoring multiple instruments simultaneously. |

## Examples and Use Cases

| HTTP (Rest API)                                                                                                                                                                                                                                                    | WebSocket (Real-time data)                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ul><li>Fetch the current price of Bitcoin</li><li>Get historical price data of Apple stocks for the past year</li><li>Convert US Dollars to Euros using the latest conversion rate</li><li>Convert US Dollars to Euros using the latest conversion rate</li></ul> | <ul><li>Monitor price fluctuations of NASDAQ, Dow Jones, and S\&P500 in real-time.</li><li>Track currency pairs like EUR/USD, GBP/USD for forex trading platforms.</li><li>Monitor multiple cryptocurrencies like Bitcoin, Ethereum, and Litecoin for instant trade decisions.</li></ul> |
