UNPKG

@coinset/bitmart

Version:

Universal BitMart API client

50 lines 1.84 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "./_utils.js", "./constants.js", "../deps.js"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchContract = void 0; const _utils_js_1 = require("./_utils.js"); const constants_js_1 = require("./constants.js"); const deps_js_1 = require("../deps.js"); const reviver = (key, value) => { if ([ "last_price", "index_price", "last_funding_rate", "price_change_percent_24h", "volume_24h", "high_price", "low_price", "legal_coin_price", ].includes(key) && (0, deps_js_1.isString)(value)) { return Number(value); } return value; }; /** Get the latest market quotations of the contract. * ```ts * import { fetchContract } from "https://deno.land/x/bitmart@$VERSION/mod.ts" * await fetchContract() * ``` * @see https://developer-pro.bitmart.com/en/contract/quotation/tickers.html */ function fetchContract(options, init) { const url = new URL("contract/v1/tickers", constants_js_1.BASE_URL); const _contractSymbol = options?.contractSymbol; if (_contractSymbol) { url.searchParams.set("contract_symbol", _contractSymbol); } return (0, _utils_js_1.jsonFetch)(url, init, { parseJson: reviver, }); } exports.fetchContract = fetchContract; }); //# sourceMappingURL=contract.js.map