Check Bitcoin Balance with mybitx api https GET url

Charles Adeyemo Source

I am new to integrating bitcoin API to my PHP page, I have created a bitcoin account with luno, I have created API Key.

I have been given this url to get balance using my generated API Key:

$ curl -u keyid:keysecret https://api.mybitx.com/api/1/balance

Can anybody help with a proper example on how I can use my API with this given url to display my wallet balance on a PHP page?

phpapibitcoin

Answers

answered 3 months ago Michael #1

The easiest way I know to convert curl commands to executable PHP code is to use this site: https://incarnate.github.io/curl-to-php/

Just add your curl command:

curl -u keyid:keysecret https://api.mybitx.com/api/1/balance

to the textbox that says "Paste curl here". Then take the PHP that is output and integrate it into your app.

answered 3 months ago Sudheesh Singanamalla #2

You can use the PHP Requests library for an easy way to make HTTP Requests. Your curl command can be converted as follows:

<?php
    include('vendor/rmccue/requests/library/Requests.php');
    Requests::register_autoloader();
    // Use additional headers if necessary
    $headers = array();
    // Create authorization using key and secret.
    $options = array('auth' => array('keyid', 'keysecret'));
    // Create the GET request to the URL
    $response = Requests::get('https://api.mybitx.com/api/1/balance', $headers, $options);
    // The result is available in $response
?>

comments powered by Disqus