JasonPellerin / api-v1-client-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blockchain API library (PHP, v1)

An official PHP library for interacting with the blockchain.info API.

Getting Started

Download the source or clone the repository. This php library works with the Composer package manager. Navigate to the root of the repository and run

$ composer install

This will create the /vendor folder in the repository root. In the php source, simply:

// Include the autoload.php from its vendor directory
require 'vendor/autoload.php'

// Create the base Blockchain class instance
$Blockchain = new \Blockchain\Blockchain();

All functionality is provided through the Blockchain object.

###Call Limits

The official documentation lists API call limits, which may be bypassed with an API code. If you use a code, enter it when you create the Blockchain object:

$Blockchain = new \Blockchain\Blockchain($my_api_code);

If you need an API code, you may request one here.

###Network Timeouts

Set the cURL timeout, in seconds, with the setTimeout member function:

$Blockchain->setTimeout($timeout_seconds);

The default network timeout is 60 seconds.

A Note about Bitcoin Values

All Bitcoin values returned by the API are in string float format, in order to preserve full value precision. It is recommended that all arithmetic operations performed on Bitcoin values within PHP utilize the bcmath functions as follows:

#####bcadd Add Two Numbers

$result = bcadd("101.234115", "34.92834753", 8); // "136.16246253"

#####bcsub Subtract Two Numbers

$result = bcsub("101.234115", "34.92834753", 8); // "66.30576747"

#####bcmul Multiply Two Numbers

$result = bcmul("101.234115", "34.92834753", 8); // "3535.940350613"

#####bcdiv Divide Two Numbers

$result = bcdiv("101.234115", "34.92834753", 8); // "2.89833679"

The 8 in the final parameter of each bcmath function call represents the numerical precision to keep in the result.

More help on the bcmath functions can be found in the PHP BC Math documentation.

Documentation

Block explorer - Access details of the Bitcoin blockchain

Create Wallets - Create new Blockchain wallets

Exchange Rates - See the value of Bitcoin relative to world currencies

Push Transaction - Push raw transactions to the Bitcoin network

Receive - The easiest way to accept Bitcoin payments

Statistics - Bitcoin network statistics

Wallet - Send and receive Bitcoin programmatically

Dependencies

The library depends on having the curl and bcmath modules enabled in your PHP installation.

About

License:MIT License


Languages

Language:PHP 100.0%