Laravel cryptocurrency trading APIs.

Related tags

API lypto-api
Overview

Lypto API

Laravel cryptocurrency trading APIs.

Installation

Requirements

  • Minimum Laravel version 7.0

Use the following command to install:

composer require obydul/lypto-api

Run the following command to publish config file:

php artisan vendor:publish --provider="Obydul\LyptoAPI\LyptoAPIServiceProvider" --tag="config"

(Optional) Laravel 5.5 uses package auto-discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery,

// add the service provider to your `$providers` array in `config/app.php` file
Obydul\LyptoAPI\LyptoAPIServiceProvider::class

// and add these lines to `$aliases` array
'Binance' => Obydul\LyptoAPI\Facades\Binance::class,
'TAAPI' =>Obydul\LyptoAPI\Facades\TAAPI::class,

Clear application config, cache (optional):

php artisan optimize

Installation completed.

Configuration

After installation, set API key and secret in the .env file.

// exchange
LYPTO_API_MODE="sandbox" // sanbox or live
LYPTO_API_BINANCE_KEY="your-binane-api-key"
LYPTO_API_BINANCE_SECRET="your-binane-api-secret"

// tools
LYPTO_API_TAAPI_SECRET="your-taapi-secret"

Exchanges & Tools

Exchanges

Supported exchanges and features:

Exchange Features
Binance Spot trade only

We will add more exchanges and APIs soon.

Tools

Indicator API list: | Name | Features |--- | --- | | TAAPI | Provides technical analysis indicator data

Usage

Create a Lypto request:

use Obydul\LyptoAPI\Libraries\LyptoRequest;

$request = new LyptoRequest();
$request->param1 = 'Value 1';
$request->param2 = "Value 2";
$request->param2 = "Value 2";

Pass Laypto request to exchange's function:

// exchange object
$exchange->functionName($request);

// exchange facade
Exchange::functionName($request);

Binance

Take a look at Binance APIs and parameters.

use Obydul\LyptoAPI\Exchanges\Binance;

// create a Binance object
$binance = new Binance();

// create order
$binance->createOrder($request);

// using facade
use Obydul\LyptoAPI\Facades\Binance;

Binance::createOrder($request);

Pass api key, secret & mode without .env file:

$api_key = "YOUR_API_KEY";
$api_secret = "YOUR_API_SECRET";
$mode = "sandbox"; // default is live
$this->binance = new Binance($api_key, $api_secret, $mode); // mode doesn't need to pass for live
$this->binance = new Binance($api_key, $api_secret); // live

// using facade
use Obydul\LyptoAPI\Facades\Binance;
$account_info = Binance::config($api_key, $api_secret, $mode)->accountInfo(); // sandbox
$account_info = Binance::config($api_key, $api_secret)->accountInfo(); // live

Available methods:

Test server:

Title Method
Test Connectivity ping()
Check Server Time time()
Exchange Information exchangeInfo()

Spot trade:

Title Method
Get current account information accountInfo($request)
Current price of a pair currentPrice($request)
Create order createOrder($request)
Cancel an active order cancelOrder($request)
Cancels all active orders on a symbol cancelOpenOrders($request)
Check an order's status queryOrder($request)
Get all open orders on a symbol currentOpenOrders($request)
Get all account orders; active, canceled, or filled allOrders($request)
Get trades for a specific account and symbol accountTradeList($request)
Create a new OCO createOCO($request)
Cancel an entire Order List cancelOCO($request)
Retrieves a specific OCO based on provided optional parameters queryOCO($request)
Retrieves all OCO based on provided optional parameters queryAllOCO($request)
Retrieves open OCO queryOpenOCO($request)
24hr Ticker Price Change Statistics priceChange24Hr($request
Average price of a pair (5 mins) avgPrice($request

TAAPI

TAAPI provides technical analysis (TA) indicator data.

Let's have a look at the uasge:

use Obydul\LyptoAPI\Tools\TAAPI;

$taapi = new TAAPI();
$request = new LyptoRequest();
$indicator_endpoint = "rsi";
$taapi->get($indicator_endpoint, $request);

// call via facade
use Obydul\LyptoAPI\Facades\TAAPI;

TAAPI::get($indicator_endpoint, $request);

Pass api key without .env file:

$api_key = "YOUR_API_KEY";
$response = TAAPI::config($api_key)->get($indicator_endpoint, $request);

Examples

Binance
use Obydul\LyptoAPI\Exchanges\Binance;
use Obydul\LyptoAPI\Libraries\LyptoRequest;

private $binance;

/**
 * constructor.
 */
public function __construct()
{
    $this->binance = new Binance();
}

// account info
$account_info = $this->binance->accountInfo();
dd($account_info);

// account info using facade
use Obydul\LyptoAPI\Facades\Binance;

$account_info = Binance::accountInfo();
dd($account_info);

// create order
$request = new LyptoRequest();
$request->symbol = 'BTCUSDT';
$request->side = "SELL";
$request->type = "LIMIT";
$request->timeInForce = "GTC";
$request->quantity = 0.01;
$request->price = 9000;
$request->newClientOrderId = "my_order_id_1112";
$create_order = $this->binance->createOrder($request);
dd($create_order);

// account trade list
$request = new LyptoRequest();
$request->symbol = "BTCUSDT";
$trade_list = $this->binance->accountTradeList($request);
dd($trade_list);
TAAPI
use Obydul\LyptoAPI\Facades\TAAPI;
use Obydul\LyptoAPI\Libraries\LyptoRequest;

// lypto request
$request = new LyptoRequest();
$request->exchange = 'binance';
$request->symbol = "BTC/USDT";
$request->interval = "1h";

// indicator endpoint
$indicator_endpoint = "macd";

// get data
$response = TAAPI::get($indicator_endpoint, $request);

dd($response);

Output:

array:3 [▼
  "valueMACD" => 289.32379962478
  "valueMACDSignal" => 257.39665148897
  "valueMACDHist" => 31.92714813581
]

Information

License

The MIT License (MIT). Please see license file for more information.

Others

In case of any issues, kindly create one on the Issues section.

Thank you for installing LyptoAPI ❤️ .

You might also like...
The server component of API Platform: hypermedia and GraphQL APIs in minutes

API Platform Core API Platform Core is an easy to use and powerful system to create hypermedia-driven REST and GraphQL APIs. It is a component of the

Pure PHP APIs with PostgreSQL database, with HTML, CSS & JS simple frontend

The root of the project is html/index.html The folder needs to be put in htdocs folder to run correctly // this link should open the main page if the

PHP library/SDK for Crypto APIs 2.0 using Guzzle version 7

cryptoapis/sdk-guzzle7 Crypto APIs 2.0 is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain an

Proposed REST and GraphQL APIs for Concrete CMS 9.2+
Proposed REST and GraphQL APIs for Concrete CMS 9.2+

Concrete CMS API Proposal 2022 Hello there! This is a package for Concrete CMS (9.1.1+) that adds a proposed REST API. This API is reasonably comprehe

A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.
A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.

Laravel Responder is a package for building API responses, integrating Fractal into Laravel and Lumen. It can transform your data using transformers,

Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。

Thresh Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。 安装 $ composer require telstatic/thresh -vvv 功能 生成 Markdown 文档 生成 Postman 配置文件 生

Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.
Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.

Laravel API tool kit and best API practices Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using lar

A RESTful API package for the Laravel and Lumen frameworks.
A RESTful API package for the Laravel and Lumen frameworks.

The Dingo API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own API. While the goal of

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

CORS Middleware for Laravel Implements https://github.com/asm89/stack-cors for Laravel About The laravel-cors package allows you to send Cross-Origin

Releases(v1.1.3)
Owner
Md Obydullah
Software Engineer & Ethical Hacker
Md Obydullah
A simple way of authenticating your RESTful APIs with API keys using Laravel

ApiGuard This package is no longer maintained This package is no longer maintained as Laravel already has a similar feature built-in since Laravel 5.8

Chris Bautista 691 Nov 29, 2022
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.

API Platform is a next-generation web framework designed to easily create API-first projects without compromising extensibility and flexibility: Desig

API Platform 7.7k Jan 7, 2023
Behat extension for those who want to write acceptances tests for apis

Behapi Behat extension to help write describe features related to HTTP APIs. PHP 7.3, Behat 3.7 and a discoverable php-http client are required to mak

Baptiste Clavié 32 Nov 25, 2022
Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs

Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.

Thuong Le 77 Dec 19, 2022
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
A collective list of free APIs

Public APIs A collective list of free APIs for use in software and web development Status The Project Contributing Guide • API for this project • Issu

null 222.8k Jan 4, 2023
A php library for coinex exchange apis .

Coinex API PHP Coinex digital coin exchange API for PHP Requirements PHP>=7.1 CURL PHP module Install composer require roozbeh/coinex_php Acquire acce

Roozbeh Baabakaan 3 Nov 12, 2022
PHP SDK for Checkout RESTful APIs

REST API SDK for PHP V2 To consolidate support across various channels, we have currently turned off the feature of GitHub issues. Please visit https:

PayPal 400 Nov 29, 2022
PHP SDK for PayPal RESTful APIs

Deprecation Notice: This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted. For alternatives, pl

PayPal 2.1k Jan 5, 2023
The NelmioApiDocBundle bundle allows you to generate a decent documentation for your APIs

NelmioApiDocBundle The NelmioApiDocBundle bundle allows you to generate a decent documentation for your APIs. Migrate from 3.x to 4.0 To migrate from

Nelmio 2.1k Jan 6, 2023