Calling BitStamp API using Guzzle
I’ve recently been working on integrating to the BitStamp API from a Laravel application, and I was having some problems calling it using the Guzzle PHP HTTP Client.
I’m sharing how I was finally able to make a call to the API.
The API supports 2 types of calls:
- public calls, e.g to get the market ticker
- private calls, e.g. to get your account balance. The private calls require you to pass some extra details required for authentication, i.e.
I have a function that will handle calling different endpoints on the API, so I just have to send pass the following:
- a flag,
requiresAuthto determine if we need to pass additional authentication params, and;
requestBody, which contains any
For calls that require authentication, the
signature should be passed as form_params.
One thing to note, if you pass the
endpoint parameter without a trailing slash, e.g.
ticker instead of
ticker/, you’ll get an error saying:
An example of a call to this function would be:
That’s all for now people! Back to code!