Custom SDK for API Interaction
A comprehensive guide to using our Nestia-generated SDK for interacting with the API
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:
Each module contains functions corresponding to specific API endpoints.
Connection Setup
Before making API calls, set up a connection object:
Key Modules and Endpoints
Currency Module
Retrieve Retro 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 the IPropagation
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.
Example Usage
Here’s a complete example of using the SDK to perform a swap:
This SDK provides a robust, type-safe way to interact with our API, ensuring that you can build reliable integrations with confidence.