Download the PHP package timirey/xapi-php without Composer

On this page you can find all versions of the php package timirey/xapi-php. 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 xapi-php

XTB Online Investing

Tests Latest Stable Version Total Downloads License

This PHP library provides a comprehensive and user-friendly interface for interacting with the X-Trade Brokers (XTB) xStation5 Trading API. It supports a wide range of functionalities, including account management, trade execution, market data retrieval, and real-time streaming commands via socket, making it an ideal tool for developers looking to integrate advanced trading features and live market data into their applications.

Table of contents

Installation

Install the package via Composer.

Usage

Basic usage example.

Subscribe to a stream channel.

Available commands

Request-Reply commands are performed on main connection socket. The reply is sent by main connection socket.

login

Logs in to the xStation5 API.

logout

Logs out from the xStation5 API.

Available streaming commands

fetchBalance (getBalance)

Allows to get actual account indicators values in real-time, as soon as they are available in the system.

fetchCandles (getCandles)

Subscribes for and unsubscribes from API chart candles. The interval of every candle is 1 minute. A new candle arrives every minute.

fetchKeepAlive (getKeepAlive)

Subscribes for and unsubscribes from 'keep alive' messages. A new 'keep alive' message is sent by the API every 3 seconds.

fetchNews (getNews)

Subscribes for and unsubscribes from news.

fetchProfits (getProfits)

Subscribes for and unsubscribes from profits.

fetchTickPrices (getTickPrices)

Establishes subscription for quotations and allows to obtain the relevant information in real-time, as soon as it is available in the system.

fetchTrades (getTrades)

Establishes subscription for user trade status data and allows to obtain the relevant information in real-time, as soon as it is available in the system.

fetchTradeStatus (getTradeStatus)

Allows to get status for sent trade requests in real-time, as soon as it is available in the system.

pingStream (ping)

Regularly calling this function is enough to refresh the internal state of all the components in the system.

Retrieving trading data

getAllSymbols

Retrieves information about all symbols.

getCalendar

Returns a calendar with market events.

getChartLastRequest

Returns chart info from the start date to the current time.

getChartRangeRequest

Returns chart info from the start date to the current time.

getCommissionDef

Returns the calculation of commission and rate of exchange.

getCurrentUserData

Returns information about account currency and leverage.

getIbsHistory

Returns IBs data from the given time range.

getMarginLevel

Returns various account indicators.

getMarginTrade

Returns expected margin for a given instrument and volume.

getNews

Returns news from the trading server which were sent within a specified period.

getProfitCalculation

Calculates estimated profit for given deal data.

getServerTime

Returns the current time on the trading server.

getStepRules

Returns a list of step rules for DMAs.

getSymbol

Retrieves information about a specific symbol.

getTickPrices

Returns an array of current quotations for given symbols.

getTradeRecords

Returns an array of trades listed in orders argument.

getTrades

Returns an array of user's trades.

getTradesHistory

Returns an array of user's trades which were closed within a specified period.

getTradingHours

Returns quotes and trading times.

getVersion

Returns the current API version.

ping

Regularly calling this function is enough to refresh the internal state of all the components in the system.

tradeTransaction

Starts a trade transaction.

tradeTransactionStatus

Returns the current transaction status.

Error handling

Custom exceptions for handling request errors.

ErrorResponseException

Thrown when the API returns an error (e.g., invalid password). Provides error code and description.

All error codes and descriptions can be found in the official documentation.

InvalidResponseException

Thrown when a request fails and the API does not return a proper error response (e.g., invalid or incomplete response).

InvalidPayloadException

Thrown when for some reason the payload is invalid (usually invalid response from the xApi).

SocketException

Thrown when socket fails to connect/read/write for some reason.

Testing

This package uses the PestPHP framework for testing.

License

This library is open-sourced software licensed under the MIT license.

Reference

For more detailed documentation, please refer to the XTB xStation5 Trading API Documentation.


All versions of xapi-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 timirey/xapi-php contains the following files

Loading the files please wait ....