UNPKG

@magiceden/magiceden-sdk

Version:

A TypeScript SDK for interacting with Magic Eden's API across multiple chains.

64 lines (63 loc) 1.6 kB
import { AxiosRequestConfig } from 'axios'; import { RetryablePromise } from '../../helpers'; /** * API configuration options */ export interface ApiOptions { /** * API key */ apiKey: string; /** * Headers to send with requests * * @default { * 'Content-Type': 'application/json', * 'Authorization': `Bearer ${apiKey}`, * } */ headers?: Record<string, string>; /** * Timeout for requests * * @default 30000 */ timeout?: number; /** * Whether the API should reject unauthorized requests * * @default true */ rejectUnauthorized?: boolean; } /** * Manages API interactions with the Magic Eden API */ export declare class ApiManager { private readonly client; constructor(baseURL: string, options: ApiOptions); /** * Makes a GET request */ get<T>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): RetryablePromise<T>; /** * Makes a POST request */ post<T>(url: string, data?: any, config?: AxiosRequestConfig): RetryablePromise<T>; /** * Makes a PUT request */ put<T>(url: string, data?: any, config?: AxiosRequestConfig): RetryablePromise<T>; /** * Makes a DELETE request */ delete<T>(url: string, config?: AxiosRequestConfig): RetryablePromise<T>; /** * Handles request errors and converts them to appropriate error types */ private handleRequestError; /** * Safely extracts error message from response data */ private getErrorMessage; }