dexscreener-sdk
Version:
A TypeScript wrapper for the DEX Screener API, providing easy access to token profiles, boosts, orders, pairs, and more.
21 lines (20 loc) • 737 B
JavaScript
import axios from 'axios';
import { BASE_URL } from '../config.js';
import { handleApiError } from '../utils/errors.js';
import { Order } from '../models/Order.js';
/**
* Fetches orders for a given token.
* @param chainId - The blockchain identifier (e.g., "solana").
* @param tokenAddress - The token address.
* @returns A promise that resolves to an array of Order instances.
*/
export const getOrdersForToken = async (chainId, tokenAddress) => {
try {
const url = `${BASE_URL}/orders/v1/${chainId}/${tokenAddress}`;
const response = await axios.get(url);
return response.data.map((data) => new Order(data));
}
catch (error) {
return handleApiError(error);
}
};