Socket
Book a DemoInstallSign in
Socket

fcsapi-websocket-python

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fcsapi-websocket-python

Real-time WebSocket client for Python library for Forex, Cryptocurrency, and Stock market data from FCS API

pipPyPI
Version
4.0.0
Maintainers
1

FCS WebSocket Python

Real-time WebSocket client library for Forex, Cryptocurrency, and Stock market data from FCS API.

License: MIT Python PyPI

Features

  • Real-time WebSocket - Live price updates via WebSocket connection
  • Multi-Market Support - Forex, Crypto, and Stock data
  • Frontend & Backend - Use in browser or pure Python
  • Auto-Reconnect - Handles connection drops automatically
  • No Dependencies - Frontend uses Python built-in modules

Installation

pip install fcsapi-websocket-python

For backend usage, also install:

pip install websocket-client

Demo

Use demo API key for testing: fcs_socket_demo

Frontend (Browser-based)

For web applications that display real-time prices in the browser.

Structure

frontend/
├── fcs-client-lib.js      # JavaScript WebSocket client
└── examples/
    ├── crypto_example.py  # Crypto prices in browser
    ├── forex_example.py   # Forex prices in browser
    └── stock_example.py   # Stock prices in browser

Quick Start

cd frontend/examples
python crypto_example.py
# Open http://localhost:5000

How it works

  • Python serves HTML page with embedded JavaScript
  • JavaScript (fcs-client-lib.js) connects to WebSocket
  • Real-time updates displayed in browser

Backend (Pure Python)

For server-side applications, bots, or scripts that need real-time data without a browser.

Structure

backend/
├── fcs_client_lib.py      # Python WebSocket client
└── examples/
    ├── crypto_example.py  # Terminal crypto prices
    ├── forex_example.py   # Terminal forex prices
    └── stock_example.py   # Terminal stock prices

Quick Start

pip install websocket-client
cd backend/examples
python crypto_example.py

Usage

from backend import FCSClient

client = FCSClient('YOUR_API_KEY')

@client.on_message
def handle_message(data):
    if data.get('type') == 'price':
        print(data)

client.connect()
client.join('BINANCE:BTCUSDT', '1D')
client.run_forever()

Backend API

from backend import FCSClient

# Create client
client = FCSClient(api_key, url=None)

# Connect
client.connect()
client.run_forever(blocking=True)  # blocking=False for background

# Subscribe
client.join('BINANCE:BTCUSDT', '1D')
client.leave('BINANCE:BTCUSDT', '1D')
client.remove_all()

# Disconnect
client.disconnect()

# Event callbacks (decorators)
@client.on_connected
@client.on_message
@client.on_close
@client.on_error
@client.on_reconnect

Symbol Format

MarketFormatExamples
ForexFX:PAIRFX:EURUSD, FX:GBPUSD
CryptoEXCHANGE:PAIRBINANCE:BTCUSDT, BINANCE:ETHUSDT
StockEXCHANGE:SYMBOLNASDAQ:AAPL, NYSE:TSLA

Timeframes

TimeframeDescription
11 minute
55 minutes
1515 minutes
1H1 hour
1D1 day
1W1 week

Message Data Format

# Price update
{
    "type": "price",
    "symbol": "BINANCE:BTCUSDT",
    "timeframe": "1D",
    "prices": {
        "mode": "candle",  # or "initial", "askbid"
        "t": 1766361600,   # Timestamp
        "o": 88658.87,     # Open
        "h": 90588.23,     # High
        "l": 87900,        # Low
        "c": 89962.61,     # Close
        "v": 8192.70,      # Volume
        "a": 89962.62,     # Ask
        "b": 89962.61      # Bid
    }
}

Get API Key

  • Visit FCS API
  • Sign up for free
  • Get your API key

Documentation

Support

License

MIT License - see LICENSE file.

Keywords

fcs

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts