Author

Topic: Coins-e.com PHP sample (Read 1942 times)

sr. member
Activity: 246
Merit: 250
July 23, 2013, 03:50:54 PM
#3
To figure out how to implement this API, you need to evaluate what you need to do. There are two types of methods, unauthenticated GET methods and authenticated POST methods. None of the GET methods need any query parameters. The POST methods take query parameters (only key and sign), and some POST parameters. The easiest way to do this would then seem to be to make two functions, one for GET methods and the other for POST methods.


1. The GET function simply needs to take the URL, and then use cURL to download it. You may need to substitute the pair yourself for those methods which need it. You then need to decode the JSON request into an array.

2. The POST functions need to take the URL and an array of POST parameters. You also need a way of providing your public and private key, which depends on your implementation. First, you need to set the nonce if not set in the parameter array. Then you need to encode the parameters in URL query string format (probably with http_build_query). This is your post data. Now you need to generate the HMAC sign. Make sure you use SHA-512 for your hash function, use your private key for the key, and post data for the message. Then use the HMAC algorithm to get the hexadecimal digest.

Code:
$sign = hash_hmac("sha512", $post_data, $PRIVATE_KEY, false);

Now, build your query string as "key=$PUBLIC_KEY&sign=$sign", and append it to the end of the url with a ?, e.g. "https://www.coins-e.com/api/v2/market/WDC_BTC/?key=547189fad79e08&sign=709ed89b0ac". Finally, use cURL to post post_data to the URL you just constructed and decode the JSON request into an array again.


Hopefully this should make it relatively straightforward and give you some pointers to start. I haven't programmed in PHP for a while but if you need some help on a specific part I could look into it for you.
legendary
Activity: 965
Merit: 1000
July 23, 2013, 12:10:36 PM
#2
I using java, but I think the API description is pretty straightforward? What exactly is your problem?
newbie
Activity: 58
Merit: 0
July 22, 2013, 10:42:13 PM
#1
Hey everyone,

I am looking at getting trading on coins-e.com however with my limited of knowledge of python, I would much rather use PHP to write my bot. Does anyone have some sort of coins-e.com PHP sample I could peruse? Or perhaps someone who knows both PHP and python? Smiley I have tried to convert the cryptsy sample (PHP), however I have yet to be successful! I would appreciate any help very much.

coins-e.com (python sample): https://www.coins-e.com/exchange/api/documentation/

cryptsy.com (PHP sample): https://www.cryptsy.com/pages/api

Thank you!

The Lysdexic Citboin
Jump to: