SDK Documentation Reference

Introduction

This reference provides detailed information about the SDK's classes, methods, properties, and usage patterns. Use the navigation on the left to explore different modules.

Getting Started

npm install my-awesome-sdk
# or
yarn add my-awesome-sdk

Import the SDK in your project:

import { Client } from 'my-awesome-sdk';

const client = new Client({ apiKey: 'YOUR_API_KEY' });

Client Class

The Client class is the entry point for interacting with the service.

ConstructorDescription
new Client(options)Creates a new client instance.

Methods

MethodSignatureDescription
connect()connect(): Promise<void>Establishes a connection to the backend.
fetchData(params)fetchData(params: object): Promise<DataResult>Retrieves data based on the provided parameters.
close()close(): voidCloses the client and releases resources.
await client.connect();
const result = await client.fetchData({ limit: 10 });
console.log(result);
client.close();

Error Handling

All SDK methods reject with an SdkError object containing code and message properties.

try {
  await client.fetchData({ invalid: true });
} catch (err) {
  if (err instanceof SdkError) {
    console.error(`Error ${err.code}: ${err.message}`);
  }
}