nysschens/tradeapp-api-client

PHP Guzzle API Client for Trade Platforms


Keywords
api, Binary Options, TradeApp, Fx Trade, CFD Trade
License
MIT

Documentation

TradeApp API Client

A skeleton repo of a PHP Guzzle API Client for Laravel to consume trading platform data.

TradeApp is an independent API client using Guzzle 7, intended for consuming data from various Global Trading Platforms.

Installation

Install using Composer, doubtless.

$ composer require nysschens/tradeapp-api-client

Usage

First, you'll need to create a client object to connect to the trading platform servers with. You will need an API username and password from whatever trade platform you subscribe to. Ask your broker for that info. Then pass those credentials into the client object for logging in, like this.

$client = new \TradeApp\ApiClient("https://<username>:<password>@<hostname>");

Assuming your credentials are valid, you are good to go!

Get countries list

/** @var \TradeApp\Responses\Country[] $countries */
$countries = $client->countries();

Register a new customer

$request = new TradeApp\Requests\Register([
    'firstName' => 'John',
    'lastName' => 'Smith',
    'email' => 'john.smith@gmail.com',
    'confirmed' => 1,
    'password' => 'qwerty',
    'phone' => '+123456789',
    'country' => 'gb',
    'locale' => 'en-GB',
    'params' => [],
    'lead' => 0,
]);

/** @var \TradeApp\Responses\Register $response */
$response = $client->register($request);

Login as user

$request = new \TradeApp\Requests\Login([
    'email' => 'nysschens@gmail.com',
    'password' => 'qwerty',
]);

/** @var \TradeApp\Responses\Login $response */
$response = $client->login($request);

Get user info

$request = new \TradeApp\Requests\Login([
    'email' => 'john.smith@gmail.com',
    'password' => 'qwerty',
]);

/** @var \TradeApp\Responses\UserInfo $response */
$response = $client->getUserInfo($request);

Running tests

Run unit tests via PHPUnit:

$ vendor/bin/phpunit tests

Note: Install dev dependencies for this package with

$ composer update --dev