UNPKG

@sudowealth/schwab-api

Version:

TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety

63 lines (62 loc) 2.31 kB
import { type EndpointMetadata } from '../../core/http'; import { ErrorResponseSchema } from '../../errors'; import { GetQuotesQueryParams, GetQuotesResponse, GetQuoteBySymbolIdPathParams, GetQuoteBySymbolIdQueryParams, GetQuoteBySymbolIdResponse } from './schema'; /** * Get quotes for multiple symbols. * * Note on partial success: This endpoint supports partial success responses, * meaning that even with a successful HTTP 200 response, some individual symbols * might contain error information rather than quote data. Use the `extractQuoteErrors` * utility function to easily identify and handle these symbol-level errors. * * @see extractQuoteErrors */ export declare const getQuotesMeta: EndpointMetadata<never, // No Path Params GetQuotesQueryParams, // Query Params never, // No Request Body GetQuotesResponse, // Response Body 'GET', // HTTP Method ErrorResponseSchema>; /** * Get a quote for a single symbol. * * **Important**: The Schwab API returns the quote data wrapped in an object with the symbol as the key, * similar to the bulk quotes endpoint format. For example: * ```json * { * "TSLA": { * "assetMainType": "EQUITY", * "symbol": "TSLA", * "quote": { "lastPrice": 342.31, ... }, * "fundamental": { ... }, * "reference": { ... } * } * } * ``` * * To easily extract the quote data, use the `extractSingleQuote` utility function: * ```typescript * const response = await client.marketData.quotes.getQuoteBySymbolId({ * pathParams: { symbol_id: 'TSLA' }, * queryParams: { fields: ['all'] } * }); * * const quote = extractSingleQuote(response, 'TSLA'); * if (quote) { * console.log(`${quote.symbol}: $${quote.quote?.lastPrice}`); * } * ``` * * Note on partial success: While this endpoint typically returns data for a single symbol, * that symbol may still contain error information rather than quote data if it's invalid. * Use the `hasSymbolError` utility function to check for symbol-level errors. * * @see extractSingleQuote * @see hasSymbolError */ export declare const getQuoteBySymbolIdMeta: EndpointMetadata<GetQuoteBySymbolIdPathParams, // Path Params GetQuoteBySymbolIdQueryParams, // Query Params never, // No Request Body GetQuoteBySymbolIdResponse, // Response Body 'GET', // HTTP Method ErrorResponseSchema>;