Download the PHP package fcsapi/websocket without Composer

On this page you can find all versions of the php package fcsapi/websocket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package websocket

FCSAPI Realtime PHP

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

This library provides PHP integration with WebSocket for live market data streaming. Uses the JavaScript client library for browser-based real-time updates.

License: MIT PHP Version Packagist

Features

Demo

Use demo API key for testing: fcs_socket_demo

Installation

Composer (Recommended)

Manual Installation

  1. Download or clone this repository
  2. Include the JavaScript library in your PHP views

Quick Start

Basic PHP Example

Laravel Blade Example

CodeIgniter Example

API Reference

JavaScript Client (Browser-side)

Constructor

Parameter Type Default Description
apiKey string required Your FCS API key
url string wss://ws-v4.fcsapi.com/ws WebSocket server URL (optional)

Methods

connect()

Connects to the WebSocket server. Returns a Promise.

disconnect()

Manually closes the connection.

join(symbol, timeframe)

Subscribe to a symbol for real-time updates.

leave(symbol, timeframe)

Unsubscribe from a symbol.

removeAll()

Unsubscribe from all symbols.

Event Callbacks

Callback Description
onconnected Fired when connection is established
onmessage Fired when data is received
onclose Fired when connection is closed
onerror Fired when an error occurs
onreconnect Fired when reconnection is successful

Configuration Options

Property Type Default Description
reconnectDelay number 3000 Delay (ms) before reconnection attempt
reconnectlimit number 5 Maximum reconnection attempts
focusTimeout number 3 Minutes before disconnect when tab is hidden (0 = never)

Message Data Format

The WebSocket sends different message types:

1. Join Confirmation

2. Profile Data (One-time on join)

3. Initial Candle Data (One-time on join)

4. Live Candle Updates (Continuous)

Primary update mode - contains all price data including OHLCV and Ask/Bid.

5. Ask/Bid Updates

Sent when only Ask/Bid data changes. All values in this message are updated.

Handling Different Price Modes

Symbol Format

Symbols must include an exchange prefix:

Market Format Examples
Forex FX:PAIR FX:EURUSD, FX:GBPUSD, FX:USDJPY
Crypto EXCHANGE:PAIR BINANCE:BTCUSDT, BINANCE:ETHUSDT
Stock EXCHANGE:SYMBOL NASDAQ:AAPL, NYSE:TSLA

Timeframes

Timeframe Description
1 1 minute
5 5 minutes
15 15 minutes
30 30 minutes
1H 1 hour
4H 4 hours
1D 1 day
1W 1 week
1M 1 month

Examples

Check the /examples folder for complete working demos:

PHP Framework Integration

Laravel

Add to your .env:

Add to config/services.php:

CodeIgniter 4

Add to your .env:

Symfony

Add to your .env:

Browser Tab Visibility

The library automatically handles browser tab visibility to save bandwidth:

Set focusTimeout = 0 to disable this feature:

Error Handling

Get API Key

  1. Visit FCS API
  2. Sign up for a free account
  3. Get your API key from the dashboard

Documentation

For complete API documentation, visit:

Support

License

MIT License - see LICENSE file for details.


All versions of websocket with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fcsapi/websocket contains the following files

Loading the files please wait ...