> For the complete documentation index, see [llms.txt](https://kbase.whitelabel-loyalty.com/developer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kbase.whitelabel-loyalty.com/developer/resources/typescript-sdk/usage.md).

# Usage

Using the SDK is simple and takes some inspiration from the AWS SDK.

For authentication examples see the [Authentication guide](/developer/resources/typescript-sdk/authentication.md) — this guide will use `StaticAuthProvider` for simplicity.

## Instructions

{% stepper %}
{% step %}

### Initializing the SDK

```ts
import { WLLRewardsSdk, StaticAuthProvider } from '@wll-sdk/api';

const wllSdk = new WLLRewardsSdk({
  apiKey: '<your-api-key>',
  authProvider: new StaticAuthProvider({
    token: '<your-token>',
  }),
  baseUrl: 'https://api.staging.rewards.wlloyalty.net/v1',
});
```

{% endstep %}

{% step %}

### Using the SDK

The SDK mostly follows the paths of endpoints shown in the [API Reference](https://docs.whitelabel-loyalty.com/rewards.html).

For example: `/rewards` would become `wllSdk.reward.list`

Here is a minimal example of initializing the SDK and fetching a list of rewards.

```ts
import { WLLRewardsSdk, StaticAuthProvider } from '@wll-sdk/api';

const wllSdk = new WLLRewardsSdk({
  apiKey: '<your-api-key>',
  authProvider: new StaticAuthProvider({
    token: '<your-token>',
  }),
  baseUrl: 'https://api.staging.rewards.wlloyalty.net/v1',
});

const rewards = await wllSdk.reward.list();

console.log(rewards); // Output: { data: [...your rewards] }
```

Different endpoints will have different requirements, such as query params, body or headers. Where necessary these should be typed.
{% endstep %}
{% endstepper %}

***

## Reference

| Property       | type           | Required? |
| -------------- | -------------- | --------- |
| `apiKey`       | `string`       | Y         |
| `authProvider` | `AuthProvider` | Y         |
| `baseUrl`      | `string`       | Y         |

***

## Limitations

Currently responses from the SDK are not typed or validated. Please ensure you do appropriate validation if this is needed for your use case.
