Using this SDK
This tutorial will walk you through the basics of creating a project that uses the Changelly Fiat API SDK.
- First, run the following command to create a default
package.json
file:
> npm init --y
- If you choose to use TypeScript, you can now add TypeScript features to this project. The following steps will install TypeScript, create a
tsconfig.json
file, and gain access to most built-in types for NodeJS:
> npm install typescript
> npx tsc --init
> npm install -D @types/node
- Add the Changelly Fiat API SDK to your project via Node Package Manager:
> npm install @changelly/fiat-api-sdk-node
- Set your API keys to an environment variable such as
CHANGELLY_PRIVATE_KEY
andCHANGELLY_PUBLIC_KEY
so that it will not be committed to source control. - Create a basic
index.ts
file for your project that creates a Changelly Fiat API client:
import { ChangellyFiatClient } from "@changelly/fiat-api-sdk-node";
const client = new ChangellyFiatClient({
privateKey: process.env["CHANGELLY_PRIVATE_KEY"],
publicKey: process.env["CHANGELLY_PUBLIC_KEY"],
});
- Make an API call and check the result:
const providers = await client.getProviderList();
console.log({ providers });