UNPKG

ordapi

Version:
237 lines (236 loc) 8.46 kB
import type { BlockInfo, BlockHash, AddressInfo, BlocksResponse, InscriptionInfo, InscriptionsResponse, OutputInfo, RuneResponse, RunesResponse, SatInfo, TransactionInfo, ServerStatus, OutputType, BlockDetails, InscriptionsIDsResponse, ChildrenInfoResponse, InscriptionID, OutputAssets, TransactionHex, InscriptionRecursive } from './types'; export declare class OrdClient { private baseUrl; private headers; constructor(baseUrl: string, headers?: HeadersInit); private fetch; private fetchPost; /** * Retrieves information about a specific address including its outputs, * inscriptions, and rune balances. * * @param {string} address - Bitcoin address to query. */ getAddressInfo(address: string): Promise<AddressInfo>; /** * Fetches details about a specific block by its height or hash. * * @param {number | BlockHash} heightOrHash - Block height (number) or block hash (string). */ getBlockInfo(heightOrHash: number | BlockHash): Promise<BlockInfo>; /** * Gets detailed block information using the recursive endpoint. * * @param {number | string} heightOrHash - Block height or hash */ getBlockInfoRecursive(heightOrHash: number | string): Promise<BlockDetails>; /** * Retrieves the total number of blocks in the blockchain. */ getBlockCount(): Promise<number>; /** * Gets the hash of the latest block. */ getBlockHash(): Promise<BlockHash>; /** * Gets the latest block hash using the recursive endpoint. * * @returns {Promise<BlockHash>} Latest block hash */ getBlockHashRecursive(): Promise<BlockHash>; /** * Gets the hash of a block at the specified height. * * @param {number} height - Block height to get hash for */ getBlockHashByHeight(height: number): Promise<BlockHash>; /** * Gets the block hash using the recursive endpoint. * * @param {number} height - Block height */ getBlockHashByHeightRecursive(height: number): Promise<BlockHash>; /** * Gets the height of the latest block. */ getBlockHeight(): Promise<number>; /** * Gets the latest block height using the recursive endpoint. */ getBlockHeightRecursive(): Promise<number>; /** * Returns the height of the latest block, the blockhashes of the last 100 blocks, and featured inscriptions from them. */ getBlocksLatest(): Promise<BlocksResponse>; /** * Gets the timestamp of the latest block. */ getBlockTime(): Promise<number>; /** * Gets block time using the recursive endpoint. */ getBlockTimeRecursive(): Promise<number>; /** * Retrieves information about a specific inscription by its ID. * * @param {string} id - Inscription ID */ getInscriptionInfo(id: string): Promise<InscriptionInfo>; /** * Gets recursive inscription information. * * @param {string} id - Inscription ID */ getInscriptionRecursive(id: string): Promise<InscriptionRecursive>; /** * Gets a list of the 100 most recent inscriptions. */ getInscriptions(): Promise<InscriptionsResponse>; /** * Retrieves information about multiple inscriptions by their IDs. * * @param {string[]} ids - Array of inscription IDs to fetch */ getInscriptionsByIds(ids: string[]): Promise<InscriptionInfo[]>; /** * Gets inscriptions for a specific page number in paginated results. * * @param {number} page - Page number to fetch */ getInscriptionsByPage(page: number): Promise<InscriptionsResponse>; /** * Gets all inscriptions in a specific block. * * @param {number} height - Block height to fetch inscriptions from */ getInscriptionsByBlock(height: number): Promise<InscriptionsResponse>; /** * Gets ID of a specific inscription at an index by sat number. The inscription id at index of all inscriptions on a sat. Index may be a negative number to index from the back. 0 being the first and -1 being the most recent for example. Requires index with --index-sats flag. * * @param {number} number - Satoshi number * @param {number} index - Inscription index */ getInscriptionOnSat(number: number, index: number): Promise<InscriptionID>; /** * Gets the first 100 inscription ids on a sat. Requires index with --index-sats flag. * * @param {number} number - Satoshi number */ getInscriptionsOnSat(number: number): Promise<InscriptionsIDsResponse>; /** * Gets paginated inscription ids for a specific satoshi. * * @param {number} number - Satoshi number * @param {number} page - Page number */ getInscriptionsOnSatByPage(number: number, page: number): Promise<InscriptionsIDsResponse>; /** * Gets a specific child inscription of a parent inscription. * * @param {string} id - Parent inscription ID * @param {number} child - Index of the child inscription */ getChild(id: string, child: number): Promise<InscriptionInfo>; /** * Gets first 100 child inscriptions IDs. * * @param {string} id - Parent inscription ID */ getChildren(id: string): Promise<InscriptionsIDsResponse>; /** * Gets paginated child inscription IDs. * * @param {string} id - Parent inscription ID * @param {number} page - Page number */ getChildrenByPage(id: string, page: number): Promise<InscriptionsIDsResponse>; /** * Gets details of the first 100 child inscriptions. * * @param {string} id - Parent inscription ID */ getChildrenInfo(id: string): Promise<ChildrenInfoResponse>; /** * Gets paginated detailed child inscription information. * * @param {string} id - Parent inscription ID * @param {number} page - Page number */ getChildrenInfoByPage(id: string, page: number): Promise<ChildrenInfoResponse>; /** * Gets parent inscription IDs. * * @param {string} id - Child inscription ID */ getParents(id: string): Promise<InscriptionsResponse>; /** * Gets paginated parent inscription IDs. * * @param {string} id - Child inscription ID * @param {number} page - Page number */ getParentsByPage(id: string, page: number): Promise<InscriptionsResponse>; /** * Retrieves information about a specific UTXO. * * @param {string} outpoint - Transaction outpoint in format {txid}:{vout} */ getOutput(outpoint: string): Promise<OutputInfo>; /** * Gets assets held by an UTXO. * * @param {string} outpoint - Transaction outpoint */ getOutputAssets(outpoint: string): Promise<OutputAssets>; /** * Gets information about multiple UTXOs. * * @param {string[]} outpoints - Array of outpoints to fetch */ getOutputs(outpoints: string[]): Promise<OutputInfo[]>; /** * Gets all UTXOs for a specific address, optionally filtered by type. * * @param {string} address - Bitcoin address to get outputs for * @param {OutputType} [type] - Optional filter for specific output types */ getOutputsByAddress(address: string, type?: OutputType): Promise<OutputInfo[]>; /** * Gets information about a specific rune by name. * * @param {string} name - Rune name */ getRune(name: string): Promise<RuneResponse>; /** * Gets a list of the 100 most recent runes. */ getRunesLatest(): Promise<RunesResponse>; /** * Gets runes for a specific page number in paginated results. * * @param {number} page - Page number to fetch */ getRunesByPage(page: number): Promise<RunesResponse>; /** * Gets information about a specific satoshi by its number. * * @param {number} number - Satoshi number */ getSat(number: number): Promise<SatInfo>; /** * Gets information about a specific transaction. * * @param {string} txId - Transaction ID */ getTransaction(txId: string): Promise<TransactionInfo>; /** * Gets hex transaction data. * * @param {string} txid - Transaction ID */ getTransactionHex(txid: string): Promise<TransactionHex>; /** * Gets the current server status and information. */ getServerStatus(): Promise<ServerStatus>; }