The use of the Bitcoin Network API tutorial Demo

Source: Internet
Author: User
Tags sha256 algorithm

Original

http://30daydo.com/article/181

At present, it is perfect, and so on, it is updated to CSDN.

Update 2017-05-27

The official API documentation, but this document is like a draft, two basic examples are not. So feel yourself, write a ready-made example to everyone, you can have a reference.

First look at the official API documentation:


One, API usage instructions

1, Request procedure Description

1.1 Constructs the request data, the user data according to the interface rule provided by Jubi, through the program generates the signature and the data collection to transmit to the Jubi;

1.2 sends the request data, The constructed data collection is passed to Jubi by Post/get, and the

1.3 Jubi The request data, the server receives the request, it first carries out a security check, and then the request is processed by the authentication.

1.4 Return the response result data, Jubi the response results in JSON format feedback to the user, the specific response format, error code see the interface section,

1.5 to retrieve the returned result data processing;

2, security authentication

All private APIs need to be authenticated to the

API application can go to the Finance Center, API, request for private key and public key, private key Jubi will not be stored, once lost will not be retrieved

Note: Do not disclose these two parameters to anyone, which is as important as your password

2. Signing mechanism

Each request for the private API requires a signature verification, an example of the parameters sent:

$param = Array (

Amount + 1,

Price = = 10000,

type = ' Buy ',

nonce = 141377098123

Key = 5zi7w-4mnes-swmc4-egg9b-f2iqw-396z4-g541b

Signature = 459c69d25c496765191582d9611028b9974830e9dfafd762854669809290ed82

);
The
Nonce can be interpreted as an incrementing integer: Http://zh.wikipedia.org/wiki/Nonce

Key is the requested public key

Signature is a signature and is amount price Parameters such as type Nonce key are concatenated by the ' & ' character and are encrypted by the MD5 (private key) key for the sha256 algorithm.

 





First of all, the market is obtained by using a web crawler, and the description gives a series of parameters, what you need to do is to fill these parameters up.

If you just want to get the market, then things are much easier.

    def real_time_ticker (coin):        url = ' https://www.jubi.com/api/v1/ticker/'        try:            data = requests.post (URL, data={' coin ': coin}). JSON ()                    except Exception, E:            print e        return data


The above code shows the time to get real-time quotes. Appoint A and buy a price, quantity, and current deal quantity, price.
According to the above format, the parameters coin fill up, for example, to obtain the Zeta, Real_time_ticker (' Zet ') will return the obtained data.

{u ' sell ': U ' 0.179000 ', U ' volume ': 21828245.102822, U ' buy ': U ' 0.175010 ', U ' last ': U ' 0.179000 ', U ' Vol ': 108290769.9171, U ' High ': U ' 0.289000 ', U ' low ': U ' 0.119141 '}



All private APIs need to be certified, that is, if you want to trade, delegate, place orders, you need to use the private key and public key, and a series of encryption.

Detailed implementation:

The demo code is attached to the use of the Bitcoin Internet API tutorial

http://30daydo.com/article/181

The use of the Bitcoin Network API tutorial Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.