nowpayments-api-typescript
Version:
Nowpayments typescript API wrapper
32 lines (26 loc) • 702 B
text/typescript
import ApiConnection from './../utils/api-connection';
import { IGetEstimatePrice, IError } from './../interfaces';
export interface GetEstimatePriceResponse {
currency_from: string;
amount_from: number;
currency_to: string;
estimated_amount: number;
}
export interface GetEstimatePrice extends IGetEstimatePrice {
apiKey: string;
}
const getEstimatePrice = async ({
apiKey,
amount,
currency_from,
currency_to,
}: GetEstimatePrice): Promise<GetEstimatePriceResponse | IError> => {
const api = new ApiConnection({ apiKey });
const { data } = await api.get('/estimate', {
amount,
currency_from,
currency_to,
});
return data;
};
export default getEstimatePrice;