tatumio / tatum-js

🚀 Tatum SDK: A 💪 powerful, 🌟 feature-rich TypeScript/JavaScript 📚 library that streamlines the 🛠️ development of 🌐 blockchain applications.
https://docs.tatum.io
MIT License
360 stars 110 forks source link

API key for "@tatumio/api-client" #1117

Closed fl0ydj closed 2 months ago

fl0ydj commented 2 months ago

Describe the bug I have been using classes exposed by @tatumio/api-client (e.g. BitcoinService). Recently I started getting 401s that I have to add an API key. However, there is no option to add an api key (differently to the standard tatum SDK.

To Reproduce

import {
  BitcoinService,
} from "@tatumio/api-client";
await BitcoinService.btcGetBlockChainInfo();

Additional context SDK version:

    "@tatumio/api-client": "^2.2.81",
    "@tatumio/tatum": "^4.2.35",
fl0ydj commented 2 months ago

Any help would be appreciated!

Hathoriel commented 2 months ago

Hello @fl0ydj You can declare api client like this

import { TatumBtcSDK } from '@tatumio/btc'

const btcSDK = TatumBtcSDK({ apiKey: 'your-api-key' })
const { mnemonic, xpub } = await btcSDK.wallet.generateWallet()

console.log(`Created a wallet with ${mnemonic} and public key ${xpub}.`)

For more examples check out https://github.com/tatumio/tatum-js/tree/v2/examples. Have a nice day.

fl0ydj commented 2 months ago

Hey @Hathoriel, my question is about the "@tatumio/api-client". There you can't pass an argument for the api key. E.g.

import {
  BitcoinService,
} from "@tatumio/api-client";
await BitcoinService.btcGetBlockChainInfo();
fl0ydj commented 2 months ago

Ok seeing now that the SDK reexports the api client fully. Thanks for the pointer then.

fl0ydj commented 2 months ago

Ok nope doesnt fix this. Opened a new issue for this specifically then: https://github.com/tatumio/tatum-js/issues/1119