Custom SDK for API Interaction
Our custom SDK, generated using Nestia, provides a type-safe and efficient way to interact with our API. This document outlines the structure, usage, and key features of the SDK.SDK Structure
The SDK is organized into modules that mirror the API’s structure:Connection Setup
Before making API calls, set up a connection object:Key Modules and Endpoints
Currency Module
Retrieve Beam token details:Swap Module
Get swap data for native tokens:Liquidity Module
The liquidity module is further divided into submodules:Type Safety
The SDK provides strong type safety through detailed input and output type definitions:Error Handling
The SDK uses theIPropagation type for responses, which includes error handling capabilities:
Metadata
Each endpoint function includes metadata about the HTTP method, path, and request/response types:Best Practices
- Type Inference: Leverage TypeScript’s type inference to ensure you’re providing correct parameters.
- Error Handling: Always wrap API calls in try-catch blocks to handle potential errors gracefully.
- Connection Management: Reuse the connection object when making multiple calls to improve efficiency.
- Modular Imports: Import only the modules you need to keep your bundle size small.