butschster / kraken-api-client

The most powerful and extendable REST API / Websocket client for Kraken.com. Built on PHP8.0
MIT License
44 stars 17 forks source link

Support for multiple API keys #20

Closed kovinet closed 5 months ago

kovinet commented 1 year ago

I am building Kraken trading bot, but I will have multi user support. Meaning each user will enter their own Kraken API key in the interface.

What would be the best way to go about this? As I see for now KRAKEN_KEY and KRAKEN_SECRET are loaded directly from environment in the service provider, which makes them global. And I don't see any methods to set them later on runtime...

butschster commented 5 months ago

Create a new client instance for each key pair

$client = new \Butschster\Kraken\Client(
    new GuzzleHttp\Client(),
    new \Butschster\Kraken\NonceGenerator(),
    (new \Butschster\Kraken\Serializer\SerializerFactory())->build(),
    'api-key',      // <====== Key
    'api-secret'   // <====== Secret
);