@binance/fiat
Version:
Official Binance Fiat Connector - A lightweight library that provides a convenient interface to Binance's Fiat REST API.
323 lines (316 loc) • 11.7 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
// src/fiat.ts
import { buildUserAgent, ConfigurationRestAPI as ConfigurationRestAPI3, FIAT_REST_API_PROD_URL } from "@binance/common";
// package.json
var name = "@binance/fiat";
var version = "2.0.5";
// src/rest-api/index.ts
var rest_api_exports = {};
__export(rest_api_exports, {
FiatApi: () => FiatApi,
RestAPI: () => RestAPI
});
// src/rest-api/modules/fiat-api.ts
import {
assertParamExists,
sendRequest
} from "@binance/common";
var FiatApiAxiosParamCreator = function(configuration) {
return {
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
*
* Weight: 90000
*
* @summary Get Fiat Deposit/Withdraw History (USER_DATA)
* @param {string} transactionType 0-buy,1-sell
* @param {number} [beginTime]
* @param {number} [endTime]
* @param {number} [page] default 1
* @param {number} [rows] default 100, max 500
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getFiatDepositWithdrawHistory: async (transactionType, beginTime, endTime, page, rows, recvWindow) => {
assertParamExists("getFiatDepositWithdrawHistory", "transactionType", transactionType);
const localVarQueryParameter = {};
if (transactionType !== void 0 && transactionType !== null) {
localVarQueryParameter["transactionType"] = transactionType;
}
if (beginTime !== void 0 && beginTime !== null) {
localVarQueryParameter["beginTime"] = beginTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (page !== void 0 && page !== null) {
localVarQueryParameter["page"] = page;
}
if (rows !== void 0 && rows !== null) {
localVarQueryParameter["rows"] = rows;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/sapi/v1/fiat/orders",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
* paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have:
* Cash Balance
* Credit Card
* Online Banking
* Bank Transfer
*
* Weight: 1
*
* @summary Get Fiat Payments History (USER_DATA)
* @param {string} transactionType 0-buy,1-sell
* @param {number} [beginTime]
* @param {number} [endTime]
* @param {number} [page] default 1
* @param {number} [rows] default 100, max 500
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getFiatPaymentsHistory: async (transactionType, beginTime, endTime, page, rows, recvWindow) => {
assertParamExists("getFiatPaymentsHistory", "transactionType", transactionType);
const localVarQueryParameter = {};
if (transactionType !== void 0 && transactionType !== null) {
localVarQueryParameter["transactionType"] = transactionType;
}
if (beginTime !== void 0 && beginTime !== null) {
localVarQueryParameter["beginTime"] = beginTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (page !== void 0 && page !== null) {
localVarQueryParameter["page"] = page;
}
if (rows !== void 0 && rows !== null) {
localVarQueryParameter["rows"] = rows;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/sapi/v1/fiat/payments",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var FiatApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = FiatApiAxiosParamCreator(configuration);
}
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
*
* Weight: 90000
*
* @summary Get Fiat Deposit/Withdraw History (USER_DATA)
* @param {GetFiatDepositWithdrawHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFiatDepositWithdrawHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof FiatApi
* @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History Binance API Documentation}
*/
async getFiatDepositWithdrawHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFiatDepositWithdrawHistory(
requestParameters?.transactionType,
requestParameters?.beginTime,
requestParameters?.endTime,
requestParameters?.page,
requestParameters?.rows,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
* paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have:
* Cash Balance
* Credit Card
* Online Banking
* Bank Transfer
*
* Weight: 1
*
* @summary Get Fiat Payments History (USER_DATA)
* @param {GetFiatPaymentsHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFiatPaymentsHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof FiatApi
* @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Payments-History Binance API Documentation}
*/
async getFiatPaymentsHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFiatPaymentsHistory(
requestParameters?.transactionType,
requestParameters?.beginTime,
requestParameters?.endTime,
requestParameters?.page,
requestParameters?.rows,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
};
// src/rest-api/rest-api.ts
import { sendRequest as sendRequest2 } from "@binance/common";
var RestAPI = class {
constructor(configuration) {
this.configuration = configuration;
this.fiatApi = new FiatApi(configuration);
}
/**
* Generic function to send a request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param params - Query parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendRequest(endpoint, method, params = {}) {
return sendRequest2(this.configuration, endpoint, method, params, void 0);
}
/**
* Generic function to send a signed request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param params - Query parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendSignedRequest(endpoint, method, params = {}) {
return sendRequest2(this.configuration, endpoint, method, params, void 0, {
isSigned: true
});
}
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
*
* Weight: 90000
*
* @summary Get Fiat Deposit/Withdraw History (USER_DATA)
* @param {GetFiatDepositWithdrawHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFiatDepositWithdrawHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History Binance API Documentation}
*/
getFiatDepositWithdrawHistory(requestParameters) {
return this.fiatApi.getFiatDepositWithdrawHistory(requestParameters);
}
/**
* Get Fiat Deposit/Withdraw History
*
* If beginTime and endTime are not sent, the recent 30-day data will be returned.
* paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have:
* Cash Balance
* Credit Card
* Online Banking
* Bank Transfer
*
* Weight: 1
*
* @summary Get Fiat Payments History (USER_DATA)
* @param {GetFiatPaymentsHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFiatPaymentsHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Payments-History Binance API Documentation}
*/
getFiatPaymentsHistory(requestParameters) {
return this.fiatApi.getFiatPaymentsHistory(requestParameters);
}
};
// src/fiat.ts
var Fiat = class {
constructor(config) {
const userAgent = buildUserAgent(name, version);
if (config?.configurationRestAPI) {
const configRestAPI = new ConfigurationRestAPI3(
config.configurationRestAPI
);
configRestAPI.basePath = configRestAPI.basePath || FIAT_REST_API_PROD_URL;
configRestAPI.baseOptions = configRestAPI.baseOptions || {};
configRestAPI.baseOptions.headers = {
...configRestAPI.baseOptions.headers || {},
"User-Agent": userAgent
};
this.restAPI = new RestAPI(configRestAPI);
}
}
};
// src/index.ts
import {
FIAT_REST_API_PROD_URL as FIAT_REST_API_PROD_URL2,
ConnectorClientError,
RequiredError,
UnauthorizedError,
ForbiddenError,
TooManyRequestsError,
RateLimitBanError,
ServerError,
NetworkError,
NotFoundError,
BadRequestError
} from "@binance/common";
export {
BadRequestError,
ConnectorClientError,
FIAT_REST_API_PROD_URL2 as FIAT_REST_API_PROD_URL,
Fiat,
rest_api_exports as FiatRestAPI,
ForbiddenError,
NetworkError,
NotFoundError,
RateLimitBanError,
RequiredError,
ServerError,
TooManyRequestsError,
UnauthorizedError
};
//# sourceMappingURL=index.mjs.map