@sudowealth/schwab-api
Version:
TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety
64 lines (63 loc) • 1.85 kB
TypeScript
import { type API_VERSIONS, type ENVIRONMENTS } from '../constants';
type ApiVersion = keyof typeof API_VERSIONS;
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
/**
* Logger interface that can be implemented by consuming applications
*/
export interface SchwabApiLogger {
debug: (message: string, ...args: any[]) => void;
info: (message: string, ...args: any[]) => void;
warn: (message: string, ...args: any[]) => void;
error: (message: string, ...args: any[]) => void;
}
export interface SchwabApiConfig {
/**
* Base URL for API requests
* @default API_URLS.PRODUCTION
*/
baseUrl: string;
/**
* API environment
* @default ENVIRONMENTS.PRODUCTION
*/
environment: keyof typeof ENVIRONMENTS;
/**
* Enable logging for API requests and responses
* @default false
*/
enableLogging: boolean;
/**
* Log level for API requests and responses
* @default 'info'
*/
logLevel: LogLevel;
/**
* API version to use
* @default API_VERSIONS.V1
*/
apiVersion: ApiVersion;
/**
* Timeout for API requests in milliseconds
* @default TIMEOUTS.DEFAULT_REQUEST
*/
timeout: number;
/**
* Custom logger implementation
* If not provided, a default console logger will be used
* @default undefined
*/
logger?: SchwabApiLogger;
}
/**
* Get a copy of the default API configuration
*/
export declare function getSchwabApiConfigDefaults(): SchwabApiConfig;
/**
* Resolves the environment configuration to determine the appropriate base URL
* This is the central function for environment/URL resolution
*
* @param config The configuration to resolve
* @returns The resolved base URL
*/
export declare function resolveBaseUrl(config?: Partial<SchwabApiConfig>): string;
export {};