Simple Curl based wrapper for Binance API for PHP scripts

Overview

Simple Curl based wrapper for Binance API for PHP scripts

Feaures

  • API support for SPOT data/trading
  • FAPI/DAPI support for futures data/trading
  • Curl-only implementation
  • automatic auth

Installation

Just download latest version of binance.php:

wget https://raw.githubusercontent.com/mrcrypster/binance-php/main/binance.php

Usage

First of all, include library and authenticate:

require_once 'binance.php';
binance::auth($your_key, $your_secret);

Use binance::call($method) to call any method from API documentation

Get Binance status

# include and set key/secret
require_once 'binance.php';
binance::auth($your_key, $your_secret);

$status = binance::call('/sapi/v1/system/status');
echo 'Binance API status is: ' . $status['msg'];

Get withdrawal history

$deposits = binance::call('/sapi/v1/capital/withdraw/history');
foreach ( $deposits as $deposits ) {
  print_r($deposits);
}

Get deposit history

$withdrawals = binance::call('/sapi/v1/capital/deposit/hisrec');
foreach ( $withdrawals as $withdraw ) {
  echo $withdraw['amount'] . $withdraw['coin'] . "\n";
}

Place an order (POST method example)

Second argument accepts parameters to pass to the API request. Passing HTTP method as a third argument allows you to make POST/PUSH/DELETE requests:

$response = binance::call('/api/v3/order', [
  'symbol' => 'BNBBTC',
  'side' => 'BUY',
  'type' => 'LIMIT',
  'timeInForce' => 'GTC',
  'quantity' => 10,
  'price' => 0.1
], 'POST');
print_r($response);

Get order data

$response = binance::call('/api/v3/order', [
  'symbol' => 'BNBBTC',
  'origClientOrderId' => 1, # user-generated ID for needed order
]);
print_r($response);

Cancel (delete) an order (DELETE method example)

$response = binance::call('/api/v3/order', [
  'symbol' => 'BNBBTC',
  'origClientOrderId' => 1, # user-generated ID for needed order
], 'DELETE');
print_r($response);
You might also like...
An unofficial wrapper client for lknpd.nalog.ru API

Unofficial MoyNalog API client An unofficial wrapper client for lknpd.nalog.ru API Install Via Composer $ composer require shoman4eg/moy-nalog Usage S

A Gitlab API wrapper that helps to automate common actions on CI jobs

Gitlab CI client This is a Gitlab API wrapper that helps to automate common actions on CI jobs (eg: Open a merge request, Open or close an issue etc)

A PHP Stream wrapper for Amazon S3

S3StreamWrapper A simple stream wrapper for Amazon S3. Example ?php use S3StreamWrapper\S3StreamWrapper; S3StreamWrapper::register(); $options = a

An asynchronous ClamAV wrapper written in PHP with amphp/socket

amphp-clamav An asynchronous ClamAV wrapper written with amphp/socket Installing composer require pato05/amphp-clamav Examples Ping and scan of a fil

Laravel wrapper for the Facebook Graph PHP 8 SDK

Laravel Facebook Graph SDK Installation Getting started with Laravel Facebook Graph is easy - first, install the package via composer composer require

OVHcloud APIs lightweight PHP wrapper

Lightweight PHP wrapper for OVHcloud APIs - The easiest way to use OVHcloud APIs in your PHP applications - Compatible with PHP 7.4, 8.0, 8.1 - Not affiliated with OVHcloud

laravel wrapper for dicom images services

laravel wrapper for dicom images services

A Laravel wrapper for thephpleague's Fractal package

laravel-api-response A Laravel wrapper for thephpleague's Fractal package Install Via Composer composer require lykegenes/laravel-api-response Then, a

PSR-18 compliant Circuit Breaker wrapper

Interrupt PSR-18 compliant Circuit Breaker wrapper. Acknowledgement This library is heavily inspired by: ackintosh/ganesha PrestaShop/circuit-breaker

Owner
Mr Crypster
I do large-scale crypto-trading systems (mostly binance), php frameworks and libraries for ultra-fast small-overhead prototyping
Mr Crypster
API G4RZK is a website that stores data from other websites (cURL).

API G4RZK is a website that stores data from other websites (cURL).

Angga Kurniawan 4 Sep 7, 2022
This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

Daniel Henze 3 Aug 29, 2022
Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP

MailChimp API Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP. I hate complex wrappers. This lets you get from the MailChimp API do

Drew McLellan 2k Dec 22, 2022
A PHP wrapper for Spotify's Web API.

Spotify Web API PHP This is a PHP wrapper for Spotify's Web API. It includes the following: Helper methods for all API endpoints: Information about ar

Jonathan Wilsson 796 Jan 8, 2023
Google Drive Api Wrapper by PHP

GoogleDrive Api Wrapper usage at first you need to create oauth client on google cloud platform. so go to the your google console dashboard and create

Arash Abedi 2 Mar 24, 2022
Twitch Helix API PHP Wrapper for Laravel

Laravel Twitch PHP Twitch Helix API Wrapper for Laravel 5+ ⚠️ Changes on May 01, 2020 Since May 01, 2020, Twitch requires all requests to contain a va

Roman Zipp 87 Dec 7, 2022
Google Translator Api Wrapper For Php Developers.

Google Translator Api Wrapper For Php Developers.

Roldex Stark 2 Oct 12, 2022
The Official Vultr API PHP Wrapper

WIP - This is not the final API Client. Unstable release use with caution. Vultr API PHP Client. Getting Started Must have a PSR7, PSR17, and PSR18 Co

Vultr 10 Dec 20, 2022
An elegant wrapper around Google Vision API

STILL UNDER DEVELOPMENT - DO NOT USE IN PRODUCTION Requires PHP 8.0+ For feedback, please contact me. This package provides an elegant wrapper around

Ahmad Mayahi 24 Nov 20, 2022
Laravel 8.x package wrapper library for Metatrader 5 Web API

Laravel 8.x package wrapper library for Metatrader 5 Web API

Ali A. Dhillon 10 Nov 13, 2022