PHP API call


i have a question abouth PHP codeing.

I have a PHP file on my server which is using “php curl” function to connect to a API from another website.

This other website which offer the API have a limit of 6 calls per seconds from same ip adress.

If 20 people visit my site at same time and the php file which connect to the other websites API with be executed, then i have 20 calls per second from same IP adress and i will be banned from the API or is the other website with API getting 20 different IP adress calls?

No. since your server is making the calls.

If you repeatedly request the same data, you should consider caching.

this is the API that i use:

it is for crypto currency trading. i have a already working php script to buy crypto currencys there.

now i was thinking to code somethink to allow other people to use my script, they need to call my php script and then they could use it also.

but the API is allowing only 6 API calls from the same IP adress at the same time, do you think it can be coded anyway to make it so that everybody can use my script at same time?

You could just do what the authors recommend:

Please note that there is a default limit of 6 calls per second. If you require more than this, please consider optimizing your application using the push API, the “moveOrder” command, or the “all” parameter where appropriate. If this is still insufficient, please contact support to discuss a limit raise.

I think the only solution can be if the exchanger give me a higher limit, but it is as good as not possible to reach them at the support.

How would you code it, do you think its possible to change the code and make it then possible to send for example 100 buy request at same time?

How many people making calls you have at the moment?

its only me one person now, but i was thinking if i can code somethink to allow it for more people at same time.

You know, six requests per second is quite a big number. Given people generally don’t send a request every second, you need at least 100 simultaneous users on your site. And to achieve that, in general you need several years and a team of several programmers to mend the site.

I mean that your concern looks a bit premature.

it did happen in my testings that my ip have been banned because of to many request. For example i did open a software which want to download price data, on this program 7 charts are open and every second every charts make a new request to get the actual price and then it did happen that the ip get blocked. I have change then my code little bit to let just one chart call the price for all charts.

in this case i was thinking to code somethink for multi user using, maybe i think to much complicate and 6 calls per seconds will be enough like you say.

How about you save the data from the API to a database or some other storage once per X seconds and then deliver the data from your local storage to your users? This way your program request the API only at X second interval (for updating the data in local storage).


i did get the same idea before and i have make it like that for the chart data, the candelsticks reading, because reading from my database have no limit and i can change it if needed, but here was the problem that my webhoster where i only have a shared hosting packet have disable me because of to much CPU using.

for the trading at poloniex with api using there is no other solution i think, because every user must make a own connection with own api keys and if they make that connection with my php scrupt, then always the same ip adress from me will be send to poloniex and they will disable me after some time. i dont have a idea if with a trick this can be change.

use multiple network interfaces with individual IPs and round robin over them for use with CURLOPT_INTERFACE.

that sounds like somethink new to me, does it cost much to do that? And which codeing language you need to know to make that?

it’s still PHP, and your webhosting provider can tell you the price.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.