GithubHelp home page GithubHelp logo

peter279k / api-v1-client-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gatomalo/api-v1-client-php

0.0 3.0 0.0 254 KB

Blockchain Bitcoin Developer APIs - PHP

Home Page: https://blockchain.info/api

License: MIT License

PHP 100.00%

api-v1-client-php's Introduction

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 order to use Wallet and CreateWallet functionality, you must provide an URL to an instance of service-my-wallet-v3. Before using these functionalities, call \Blockchain\Blockchain::setServiceUrl to set the URL to the instance of of service-my-wallet-v3.

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();

// Needed before calling $Blockchain->Wallet or $Blockchain->Create
$Blockchain->setServiceUrl('http://localhost:3000');

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('http://localhost:3000', $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 v2 - The easiest way to accept Bitcoin payments with the v2 Receive API

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.

api-v1-client-php's People

Contributors

assafy avatar c88lopez avatar clarkmoody avatar kmhouk avatar mdance avatar montymort avatar mpfluger avatar pdpi avatar pmaselkowski avatar shayanb avatar sp111 avatar tuzzolo avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.