Author

Topic: Poloniex API for PHP (Read 11228 times)

newbie
Activity: 1
Merit: 0
June 25, 2024, 04:27:28 AM
#28
If you are experiencing problems with your Poloniex bot, consider trying this fee trading bot. It offers a more reliable and user-friendly alternative with advanced features and robust error handling, potentially resolving the issues you're facing with your current setup.
newbie
Activity: 2
Merit: 0
June 01, 2017, 03:12:00 AM
#27
Hy guys!
I can not get a response from the poloniex server.
Always at start I have an error. API key and Secret key in the script is installed.
I tried to work with the class presented in the Polonix documentation.
Help solve this problem.  Huh

Error:
File_get_contents (......................): failed to open stream: HTTP request failed! HTTP / 1.1 403 Forbidden
 
Example code:
 
Code:
require ("poloniex.php");
$polo = new Poloniex ($key, $secret);
$ticker = $polo-> returnTicker ();
print_r ($ticker);

This code also does not work:


Code:
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
$info = json_decode($query); //now you can use the informations in php
echo $query;

p.s. In the interface of the exchange, the API has a status that has never had any connections.
 
Thank you for your help!



Can you try to echo it directly ?

Code:
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
//$info = json_decode($query); //now you can use the informations in php
echo $query;

And see the return, can you also tell me what is the version of php you are using ?

Code started an error occurs:
Warning: file_get_contents(https://poloniex.com/public?command=return24hVolume): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
PHP version 5.6

The error also occurs on the version of php 7.0
(((

Thanks for the help!

hero member
Activity: 882
Merit: 533
May 31, 2017, 09:31:13 AM
#26
Hy guys!
I can not get a response from the poloniex server.
Always at start I have an error. API key and Secret key in the script is installed.
I tried to work with the class presented in the Polonix documentation.
Help solve this problem.  Huh

Error:
File_get_contents (......................): failed to open stream: HTTP request failed! HTTP / 1.1 403 Forbidden
 
Example code:
 
Code:
require ("poloniex.php");
$polo = new Poloniex ($key, $secret);
$ticker = $polo-> returnTicker ();
print_r ($ticker);

This code also does not work:


Code:
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
$info = json_decode($query); //now you can use the informations in php
echo $query;

p.s. In the interface of the exchange, the API has a status that has never had any connections.
 
Thank you for your help!



Can you try to echo it directly ?

Code:
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
//$info = json_decode($query); //now you can use the informations in php
echo $query;

And see the return, can you also tell me what is the version of php you are using ?
newbie
Activity: 2
Merit: 0
May 30, 2017, 06:29:19 AM
#25
Hy guys!
I can not get a response from the poloniex server.
Always at start I have an error. API key and Secret key in the script is installed.
I tried to work with the class presented in the Polonix documentation.
Help solve this problem.  Huh

Error:
File_get_contents (......................): failed to open stream: HTTP request failed! HTTP / 1.1 403 Forbidden
 
Example code:
 
Code:
require ("poloniex.php");
$polo = new Poloniex ($key, $secret);
$ticker = $polo-> returnTicker ();
print_r ($ticker);

This code also does not work:


Code:
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
$info = json_decode($query); //now you can use the informations in php
echo $query;

p.s. In the interface of the exchange, the API has a status that has never had any connections.
 
Thank you for your help!
hero member
Activity: 882
Merit: 533
April 04, 2017, 07:33:08 AM
#24
Hi
I try use Poloniex API to test some script but it always say some error like this. If I access link from browser it will stuck at security check. Is it wrong with my code Sad

Code:
echo file_get_contents("https://poloniex.com/public?command=return24hVolume");


PHP Warning:  file_get_contents(https://poloniex.com/public?command=return24hVolume): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

The correct usage is :
Code: (php)
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
echo $query;

In your snipper you are asking to echo the function, always segment your code, don't try to use short codes as they are buggy, instead, declare variables and use them to work.

Now in order to use the informations you receive, do this :
Code: (php)
$url = "https://poloniex.com/public?command=return24hVolume";
$query = file_get_contents("https://poloniex.com/public?command=return24hVolume");
$info = json_decode($query); //now you can use the informations in php
echo $query;

Just remeber not to be lazy.
newbie
Activity: 1
Merit: 0
April 04, 2017, 01:44:34 AM
#23
Hi
I try use Poloniex API to test some script but it always say some error like this. If I access link from browser it will stuck at security check. Is it wrong with my code Sad

Code:
echo file_get_contents("https://poloniex.com/public?command=return24hVolume");


PHP Warning:  file_get_contents(https://poloniex.com/public?command=return24hVolume): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
sr. member
Activity: 378
Merit: 250
March 19, 2017, 12:16:26 PM
#22
what you posted isnt working, and it is just showing information that should not be public cause can be used by any atacker to harm or shut down your site
It's a spam. See how old is the OG post.

He is talking about nickelbot i think, because the library itself will work unless poloniex changes their methods, even if so, one can just change it and it will work again, i made a library for poloniex but without Private API support, i had a look at it, and the one provided here is correct, so it will work.

If this one doesn't suits you, you can use the Poloniex-node-api.
sorry if there was a missunderstanding,yes  i am talking about nickelbot
sr. member
Activity: 1372
Merit: 255
March 19, 2017, 07:05:49 AM
#21
Hello OP great app, can you teach us how to use this script to make trade, either buy or sell. Do you have a sample uploaded script and demo it how it works.
hero member
Activity: 882
Merit: 533
March 19, 2017, 05:01:10 AM
#20
what you posted isnt working, and it is just showing information that should not be public cause can be used by any atacker to harm or shut down your site
It's a spam. See how old is the OG post.

He is talking about nickelbot i think, because the library itself will work unless poloniex changes their methods, even if so, one can just change it and it will work again, i made a library for poloniex but without Private API support, i had a look at it, and the one provided here is correct, so it will work.

If this one doesn't suits you, you can use the Poloniex-node-api.
full member
Activity: 309
Merit: 102
Presale is live!
March 19, 2017, 04:58:10 AM
#19
what you posted isnt working, and it is just showing information that should not be public cause can be used by any atacker to harm or shut down your site
It's a spam. See how old is the OG post.
sr. member
Activity: 378
Merit: 250
March 18, 2017, 03:17:21 PM
#18
Hi there, Today I started to work on a PHP class to use Poloniex API in a simple way (only public API by now).
https://github.com/platedodev/Poloniex-API-for-PHP
It'll be finish in a week or two, hope you find it useful.
If you've any idea or suggestion to share with me or would like me to develop something, let me know Smiley.
Have a nice day.

Check out NickelBot. There is an API and Adapter that cover Poloniex: https://github.com/AdamCox9/nickelbot/tree/master/adapters/poloniex

I'm looking for developers to help build some custom bots: https://github.com/AdamCox9/nickelbot/tree/master/bots

You can see the sample website up and running at http://www.nickelbot.com/
what you posted isnt working, and it is just showing information that should not be public cause can be used by any atacker to harm or shut down your site
hero member
Activity: 882
Merit: 533
March 06, 2017, 09:01:16 AM
#17
Yeap ... this is the key Smiley
Thanks again

Code:

$polo = new Poloniex("L5knblahblah", "5Xnrblahblah");
$ticker = $polo->returnTicker();
print_r($ticker['BTC_ETH']['lowestAsk']);


Looks like this ticker is real time data. What would interest me is the product of some historical data on a graph plot, like XMRBTC * BTC_USDT to observe the Monero value moving over time.
This is tradeable when you can differentiate cheap vs. expensive and if currently following along Bitcoin or against it.

Interesting indeed, i would like to see the result when done.

https://poloniex.com/public?command=returnChartData¤cyPair=BTC_XMR
https://poloniex.com/public?command=returnChartData¤cyPair=USDT_BTC

Do this :

Code:
$polo = new Poloniex("L5knblahblah", "5Xnrblahblah");
$XMR = "BTC_XMR",$USDT="USDT_BTC";
$XMRh = $polo->returnCharData($XMR, 1405699200, 9999999999, 14400); // the other values are taken from poloniex api documentation
$USDTh= $polo->returnChartData($USDT, 1405699200, 9999999999, 14400);
$Info = [$XMRh, $USDTh];
echo(json_encode($Info));

You can write this in a info.php page, and then call it with ajax in annother page to read the data from, you could then process them in a highcharts or charts.js object to display the chart.
legendary
Activity: 1245
Merit: 1004
March 05, 2017, 09:30:35 PM
#16
Yeap ... this is the key Smiley
Thanks again

Code:

$polo = new Poloniex("L5knblahblah", "5Xnrblahblah");
$ticker = $polo->returnTicker();
print_r($ticker['BTC_ETH']['lowestAsk']);


Looks like this ticker is real time data. What would interest me is the product of some historical data on a graph plot, like XMRBTC * BTC_USDT to observe the Monero value moving over time.
This is tradeable when you can differentiate cheap vs. expensive and if currently following along Bitcoin or against it.
full member
Activity: 164
Merit: 100
March 04, 2017, 06:29:47 PM
#15
I was looking into this and the api but i cant see to find  does this  send back any alerts on confirmations  of a deposit etc?
member
Activity: 90
Merit: 10
February 13, 2017, 03:21:43 PM
#14
This is a poloniex lending bot built with python. https://github.com/Mikadily/poloniexlendingbot
hero member
Activity: 882
Merit: 533
February 12, 2017, 06:22:51 PM
#13
Nice work, i am also working on some libraries but only to querry prices and other informations from public API exchanges.
Coinables is awesome, i learned a lot from his videos.
I am also happy that for the first time some one used this
Code:
$uri = file_get_contents('https://poloniex.com/public?command='.$command);
Usually people calls Curl but it is like 4 or 5 lines of code, while file_get_contents is just one line, which is less time consuming especially if you have several calls to do, plus, a short code is a quick code.

Thanks nemgun.
Yea file_get_contents() is the quick and dirty way. cURL should be used for most production applications as it is more secure and is able to verify SSL certs.

Yes, but i think that all of these are going to be deprecated soon, nodejs and other langueages will soon kick PHP off the scene.
If someone wants to have an idea about security, just try to do it usin ajax requests in javascript console. you won't be able to do it unless you are on an empty tab because of the security locks, this means that file_get_contents isn't compliant, but it is still handy for tutorials, if you want to use for production, just amend the library.
legendary
Activity: 1442
Merit: 1186
February 12, 2017, 05:35:09 PM
#12
Nice work, i am also working on some libraries but only to querry prices and other informations from public API exchanges.
Coinables is awesome, i learned a lot from his videos.
I am also happy that for the first time some one used this
Code:
$uri = file_get_contents('https://poloniex.com/public?command='.$command);
Usually people calls Curl but it is like 4 or 5 lines of code, while file_get_contents is just one line, which is less time consuming especially if you have several calls to do, plus, a short code is a quick code.

Thanks nemgun.
Yea file_get_contents() is the quick and dirty way. cURL should be used for most production applications as it is more secure and is able to verify SSL certs.
hero member
Activity: 882
Merit: 533
February 12, 2017, 09:15:18 AM
#11
Nice work, i am also working on some libraries but only to querry prices and other informations from public API exchanges.
Coinables is awesome, i learned a lot from his videos.
I am also happy that for the first time some one used this
Code:
$uri = file_get_contents('https://poloniex.com/public?command='.$command);
Usually people calls Curl but it is like 4 or 5 lines of code, while file_get_contents is just one line, which is less time consuming especially if you have several calls to do, plus, a short code is a quick code.
hero member
Activity: 556
Merit: 500
February 11, 2017, 08:17:40 AM
#10
Great work, i will try it out.
Just thought about it and here it is Smiley.
full member
Activity: 166
Merit: 100
February 08, 2017, 11:47:53 PM
#9
Thanks,
I will use it for my new profitable bot.
Good job friend!
full member
Activity: 210
Merit: 100
February 07, 2017, 04:17:15 PM
#8
Yeap ... this is the key Smiley
Thanks again

Code:

$polo = new Poloniex("L5knblahblah", "5Xnrblahblah");
$ticker = $polo->returnTicker();
print_r($ticker['BTC_ETH']['lowestAsk']);

full member
Activity: 210
Merit: 100
February 07, 2017, 03:57:12 PM
#7
Thanks man
I will give it a try and get back
legendary
Activity: 1442
Merit: 1186
February 07, 2017, 12:21:17 AM
#6
I don't seem to find a simple example about how to use all these classes you guys are publishing.
A lot of code, and private and public, secret key ? wtf ? ... a lot of mambo jambo for someone that don't know oop and just want to use a simple function, to retrieve some info like

include(poloniexApi.php)
$ethSellPrice = get_eth_sell_price() -> should return best sell price at the moment the function is called
$ethBuyPrice = get_eth_buy_price() -> should return best buy price at the moment the function is called

Can anyone point me in the right direction, without having to learn all the OOP concept? I really needed for my simple page to track the profit of my small portfolio ... no bot trading, or anything fancy .. just refresh a page, these simple functions get the values, and are entered into calculation.  

OP is creating a library to be used with Polo. Libraries are always created with classes and functions.
To use his library you would first save the Poloniex.php file to your server and then require it.

Code:
require("Poloniex.php");

Then instantiate the class with your Poloniex API key and API secret.
You can have your API key and secret stored in a variable or just insert it in.

Code:
$polo = new Poloniex($key, $secret);
or
Code:
$polo = new Poloniex("L5knblahblah", "5Xnrblahblah");

Then you can start using the different functions.
One is returnTicker()

You would use it by hitting the class ($polo) then the function

Code:
$polo = new Poloniex($key, $secret);
$ticker = $polo->returnTicker();

The in-code notation tells us this will come back as an array. So we can output it with var_dump or print_r

Code:
$polo = new Poloniex($key, $secret);
$ticker = $polo->returnTicker();
print_r($ticker);

Let's look at another one that includes a parameter, returnOrderBook()

We can either enter in a currency pair or leave it blank to retrieve all.

Code:
$polo = new Poloniex($key, $secret);
$orderbook = $polo->returnOrderBook("ETHBTC");
print_r($orderbook);
or blank for all orderbooks
Code:
$polo = new Poloniex($key, $secret);
$orderbook = $polo->returnOrderBook();
print_r($orderbook);

Hope that helps. Keep going through the different public functions to see what's available.
full member
Activity: 210
Merit: 100
February 06, 2017, 06:35:06 PM
#5
I don't seem to find a simple example about how to use all these classes you guys are publishing.
A lot of code, and private and public, secret key ? wtf ? ... a lot of mambo jambo for someone that don't know oop and just want to use a simple function, to retrieve some info like

include(poloniexApi.php)
$ethSellPrice = get_eth_sell_price() -> should return best sell price at the moment the function is called
$ethBuyPrice = get_eth_buy_price() -> should return best buy price at the moment the function is called

Can anyone point me in the right direction, without having to learn all the OOP concept? I really needed for my simple page to track the profit of my small portfolio ... no bot trading, or anything fancy .. just refresh a page, these simple functions get the values, and are entered into calculation.  
legendary
Activity: 854
Merit: 1000
April 06, 2016, 06:33:07 AM
#4
Great work! I always support developers who work on using APIs Smiley Hope you continue development
tyz
legendary
Activity: 3360
Merit: 1533
April 06, 2016, 06:28:59 AM
#3
Thanks for sharing! It is definetely very useful for programmers. From time to time, I develop scripts using a various exchanges. I add you Github resource to my favourites. When I gonna use it then I will give a feedback about the quality and possible improvements.

Hi there, Today I started to work on a PHP class to use Poloniex API in a simple way (only public API by now).
https://github.com/platedodev/Poloniex-API-for-PHP
It'll be finish in a week or two, hope you find it useful.
If you've any idea or suggestion to share with me or would like me to develop something, let me know Smiley.
Have a nice day.
full member
Activity: 145
Merit: 112
To the moon!
April 05, 2016, 02:38:37 AM
#2
Hi there, Today I started to work on a PHP class to use Poloniex API in a simple way (only public API by now).
https://github.com/platedodev/Poloniex-API-for-PHP
It'll be finish in a week or two, hope you find it useful.
If you've any idea or suggestion to share with me or would like me to develop something, let me know Smiley.
Have a nice day.

Check out NickelBot. There is an API and Adapter that cover Poloniex: https://github.com/AdamCox9/nickelbot/tree/master/adapters/poloniex

I'm looking for developers to help build some custom bots: https://github.com/AdamCox9/nickelbot/tree/master/bots

You can see the sample website up and running at http://www.nickelbot.com/
newbie
Activity: 14
Merit: 0
April 03, 2016, 01:38:44 AM
#1
Hi there, Today I started to work on a PHP class to use Poloniex API in a simple way (only public API by now).
https://github.com/platedodev/Poloniex-API-for-PHP
It'll be finish in a week or two, hope you find it useful.
If you've any idea or suggestion to share with me or would like me to develop something, let me know Smiley.
Have a nice day.
Jump to: