Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KodaC's avatar
Level 1

API Call with package and Autodiscovery

Today I found an API that registers the provider directly (https://github.com/butschster/kraken-api-client)

But I am not sure how to define $client in this package. Can someone help me, or should I open an issue for this in the repository?

0 likes
8 replies
Sinnbeck's avatar

I am pretty sure it just automatically hooks into guzzle as that is what laravel uses. Do you have any errors or ?

KodaC's avatar
Level 1

I am currently unclear how to define $client so I am not getting an error yet.

$client = ?;
$balance = $client->request('private/Balance', \Butschster\Kraken\Responses\AccountBalanceResponse::class, $params);
Sinnbeck's avatar

@KodaC My guess would be this (in a controller)

public function show(\Butschster\Kraken\Contracts\Client $client)
{

}
KodaC's avatar
Level 1

Thank you. Currently this does not seem to work yet. I think I need to keep testing there.

I first tried to write a small API myself. But there I have the problem that the connection works with CURL, but not with the Laravel Http Client. But that's probably another topic :)

Sinnbeck's avatar

@KodaC Ok. If you get an errrors you can post them here, if you want help.

1 like
KodaC's avatar
Level 1

I think the API will not work for me because I need a dynamic API key and not one that is stored in the .env. Maybe I should test my API again and post the error here

Sinnbeck's avatar

@KodaC It will be from config, so you can overwrite it at runtime by doing

config(['kraken.key' => $newKey, 'kraken.secret' => $newSecret]);
KodaC's avatar
Level 1

@Sinnbeck Thank you. I give it a tray

When I use this

$client->getAccountBalance()

However, I receive

Butschster\Kraken\Responses\AccountBalanceResponse::setBalances(): Argument #1 ($assets) must be of type array, null given, called in .....\vendor\jms\serializer\src\Accessor\DefaultAccessorStrategy.php on line 117

Edit But I get this error as soon as I paste "\Butschster\Kraken\Contracts\Client $client".

Please or to participate in this conversation.