{"id":34600456,"url":"https://github.com/fcsapi/websocket-python","last_synced_at":"2026-03-13T21:31:49.891Z","repository":{"id":330631964,"uuid":"1122232271","full_name":"fcsapi/websocket-python","owner":"fcsapi","description":"Python WebSocket Library - Real-time Forex Trading Data, Cryptocurrency Prices, Stock Market Quotes | FCS API","archived":false,"fork":false,"pushed_at":"2025-12-26T10:40:59.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-28T11:14:25.190Z","etag":null,"topics":["forex-market","python","stock-market","websocket-client","websocket-library","websocket-python"],"latest_commit_sha":null,"homepage":"https://fcsapi.com/document/socket-api","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fcsapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-24T10:22:08.000Z","updated_at":"2025-12-27T07:22:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fcsapi/websocket-python","commit_stats":null,"previous_names":["fcsapi/websocket-python"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fcsapi/websocket-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcsapi%2Fwebsocket-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcsapi%2Fwebsocket-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcsapi%2Fwebsocket-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcsapi%2Fwebsocket-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcsapi","download_url":"https://codeload.github.com/fcsapi/websocket-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcsapi%2Fwebsocket-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30476281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T20:45:58.186Z","status":"ssl_error","status_checked_at":"2026-03-13T20:45:20.133Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["forex-market","python","stock-market","websocket-client","websocket-library","websocket-python"],"created_at":"2025-12-24T12:37:16.410Z","updated_at":"2026-03-13T21:31:49.882Z","avatar_url":"https://github.com/fcsapi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FCS WebSocket Python\n\nReal-time WebSocket client library for **Forex**, **Cryptocurrency**, and **Stock** market data from [FCS API](https://fcsapi.com).\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://www.python.org/)\n[![PyPI](https://img.shields.io/pypi/v/fcsapi-websocket.svg)](https://pypi.org/project/fcsapi-websocket/)\n\n## Features\n\n- **Real-time WebSocket** - Live price updates via WebSocket connection\n- **Multi-Market Support** - Forex, Crypto, and Stock data\n- **Auto-Reconnect** - Handles connection drops automatically\n- **Simple API** - Easy to use with decorators\n\n## Installation\n\n```bash\npip install fcsapi-websocket\n```\n\n## Examples\n\nTo download example files, clone the repository:\n\n```bash\ngit clone https://github.com/fcsapi/websocket-python\ncd websocket-python/examples\npython simple_example.py\n```\n\n## Demo API Key\n\nUse demo API key for testing: `fcs_socket_demo`\n\n---\n\n## Quick Start\n\n```python\nfrom fcs_client_lib import FCSClient\n\nclient = FCSClient('YOUR_API_KEY')\n\n@client.on_message\ndef handle_message(data):\n    if data.get('type') == 'price':\n        print(data)\n\nclient.connect()\nclient.join('BINANCE:BTCUSDT', '1D')\nclient.run_forever()\n```\n\n---\n\n## Usage Examples\n\n### Example 1: Simple Crypto Price\n\n```python\nfrom fcs_client_lib import FCSClient\n\nclient = FCSClient('fcs_socket_demo')\n\n@client.on_message\ndef on_message(data):\n    if data.get('type') == 'price':\n        symbol = data.get('symbol')\n        price = data['prices'].get('c')  # Close price\n        print(f'{symbol}: ${price}')\n\nclient.connect()\nclient.join('BINANCE:BTCUSDT', '1D')\nclient.run_forever()\n```\n\n### Example 2: Multiple Forex Pairs with Spread\n\n```python\nfrom fcs_client_lib import FCSClient\n\nclient = FCSClient('fcs_socket_demo')\n\n@client.on_connected\ndef on_connected():\n    print('Connected! Subscribing to forex pairs...')\n    client.join('FX:EURUSD', '1D')\n    client.join('FX:GBPUSD', '1D')\n    client.join('FX:USDJPY', '1D')\n\n@client.on_message\ndef on_message(data):\n    if data.get('type') == 'price':\n        p = data['prices']\n        symbol = data.get('symbol')\n        ask = p.get('a')\n        bid = p.get('b')\n        spread = round((float(ask) - float(bid)) * 10000, 1) if ask and bid else '--'\n        print(f'{symbol}: Ask={ask} Bid={bid} Spread={spread} pips')\n\nclient.connect()\nclient.run_forever()\n```\n\n### Example 3: Background Thread (Non-blocking)\n\n```python\nfrom fcs_client_lib import FCSClient\nimport time\n\nclient = FCSClient('fcs_socket_demo')\n\n@client.on_message\ndef on_message(data):\n    if data.get('type') == 'price':\n        print(f\"Price update: {data.get('symbol')}\")\n\n# Connect and run in background thread\nclient.connect()\nclient.run_forever(blocking=False)\n\n# Subscribe after connection\ntime.sleep(2)  # Wait for connection\nclient.join('BINANCE:ETHUSDT', '1D')\n\n# Your other code continues here...\nprint('Main thread continues...')\ntime.sleep(60)  # Keep running for 60 seconds\nclient.disconnect()\n```\n\n---\n\n## API Reference\n\n### Create Client\n\n```python\nfrom fcs_client_lib import FCSClient\n\nclient = FCSClient(api_key, url=None)\nclient.show_logs = True  # Enable console logs (default: False)\n```\n\n### Connection\n\n```python\nclient.connect()                    # Connect to server\nclient.run_forever(blocking=True)   # Start receiving (blocking=False for background)\nclient.disconnect()                 # Disconnect from server\n```\n\n### Subscription\n\n```python\nclient.join('BINANCE:BTCUSDT', '1D')   # Subscribe to symbol\nclient.leave('BINANCE:BTCUSDT', '1D')  # Unsubscribe from symbol\nclient.remove_all()                     # Unsubscribe from all\n```\n\n### Event Callbacks (Decorators)\n\n```python\n@client.on_connected\ndef on_connected():\n    print('Connected!')\n\n@client.on_message\ndef on_message(data):\n    print(data)\n\n@client.on_close\ndef on_close(code, msg):\n    print(f'Closed: {code}')\n\n@client.on_error\ndef on_error(error):\n    print(f'Error: {error}')\n\n@client.on_reconnect\ndef on_reconnect():\n    print('Reconnected!')\n```\n\n### Properties\n\n```python\nclient.is_connected          # Connection status (bool)\nclient.active_subscriptions  # Current subscriptions (dict)\nclient.reconnect_delay       # Reconnect delay in seconds (default: 3)\nclient.reconnect_limit       # Max reconnect attempts (default: 5)\nclient.show_logs             # Enable/disable console logs (default: False)\n```\n\n---\n\n## Symbol Format\n\n| Market | Format | Examples |\n|--------|--------|----------|\n| Forex | `FX:PAIR` | `FX:EURUSD`, `FX:GBPUSD` |\n| Crypto | `EXCHANGE:PAIR` | `BINANCE:BTCUSDT`, `BINANCE:ETHUSDT` |\n| Stock | `EXCHANGE:SYMBOL` | `NASDAQ:AAPL`, `NYSE:TSLA` |\n\n## Timeframes\n\n| Timeframe | Description |\n|-----------|-------------|\n| `1` | 1 minute |\n| `5` | 5 minutes |\n| `15` | 15 minutes |\n| `1H` | 1 hour |\n| `1D` | 1 day |\n| `1W` | 1 week |\n\n## Message Data Format\n\n```python\n# Price update\n{\n    \"type\": \"price\",\n    \"symbol\": \"BINANCE:BTCUSDT\",\n    \"timeframe\": \"1D\",\n    \"prices\": {\n        \"mode\": \"candle\",  # or \"initial\", \"askbid\"\n        \"t\": 1766361600,   # Timestamp\n        \"o\": 88658.87,     # Open\n        \"h\": 90588.23,     # High\n        \"l\": 87900,        # Low\n        \"c\": 89962.61,     # Close\n        \"v\": 8192.70,      # Volume\n        \"a\": 89962.62,     # Ask\n        \"b\": 89962.61      # Bid\n    }\n}\n```\n\n---\n\n## Get API Key\n\n1. Visit [FCS API](https://fcsapi.com)\n2. Sign up for free\n3. Get your API key\n\n## Documentation\n\n- [FCS API Docs](https://fcsapi.com/document/stock-api)\n- [WebSocket Guide](https://fcsapi.com/document/stock-api#websocket)\n\n## Support\n\n- Email: support@fcsapi.com\n- Website: [fcsapi.com](https://fcsapi.com)\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcsapi%2Fwebsocket-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcsapi%2Fwebsocket-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcsapi%2Fwebsocket-python/lists"}