Base API class for making HTTP requests to the Conflux Core API. Provides common functionality for API endpoints including request handling and error management.

CoreApi

Hierarchy (View Summary)

Constructors

Properties

Methods

Constructors

  • Creates an instance of CoreApi.

    Parameters

    • config: ApiConfig = ...

      Configuration object for the API

      API configuration options. Contains settings for connecting to the Conflux Core Scanner API.

      • target: ConfluxTarget

        Target network environment

      • OptionalapiKey?: string

        API key for authentication

      • Optionalhost?: string

        Custom API host URL

    Returns CoreApi

Properties

baseUrl: string

Base URL for the API endpoints

apiKey?: string

Optional API key for authenticated requests

logger: Logger<never> = ...

Logger instance for debugging and error tracking

Methods

  • Protected

    Makes an API request with the given parameters. Handles parameter sanitization, API key inclusion, and error handling.

    Type Parameters

    • T

      Type of the expected response data

    Parameters

    • endpoint: string

      API endpoint to call

    • params: Record<string, undefined | null | string | number | boolean> = {}

      Query parameters

    Returns Promise<ApiResponse<T>>

    Promise resolving to the API response

    When the API request fails or returns an error status