@binance/fiat-widget

中文文档
1.1.26发布于 2023/07/25MITTypeScriptESM + CJS近 30 天下载 2531
  1. You are not on any trade or economic sanctions lists, such as the UN Security Council Sanctions list, designated as a “Specially Designated National” by OFAC (Office of Foreign Assets Control of the U.S. Treasury Department) or placed on the U.S. Comme
原始使用文档
文档目录6 节
  1. @binance/fiat-widget
  2. Install By HTML CODE in 5 minutes
  3. install
  4. used
  5. Parameters
  6. API

@binance/fiat-widget

  1. You are not on any trade or economic sanctions lists, such as the UN Security Council Sanctions list, designated as a “Specially Designated National” by OFAC (Office of Foreign Assets Control of the U.S. Treasury Department) or placed on the U.S. Commerce Department’s “Denied Persons List”.

  2. You are not providing any restricted/prohibited business that could constitute illegal, unlawful activities

Install By HTML CODE in 5 minutes

  1. You can get your Binance.com ref_id from Binance Referral Program; and Binance.US ref_id from Binance.US Referral Program

  2. Add the codes below and input your ref_id 1). If you have both Binance.com and Binance.US ref_id, please input your ref_id under 'ref' and 'us_ref' section respectively 2). If you only have Binance.com ref_id, please input your ref_id under 'ref' and delete 'us_ref' section

<script src="https://public.bnbstatic.com/static/js/ocbs/@binance/fiat-widget.js"></script>
<div id="widget"></div>
<script>
    window.onload = function () {
        var t = document.querySelector('#widget')
        window.binanceFiatWidget.Widget(t, {
            locale: 'en',
            coinInfo: {
              fiat: '',
              crypto: '',
              isInUS: false
            },
            urlParmas: {
              us_ref: 'your us refId',
              ref: 'your refId'
            }
        })
    }
</script>

finally, check the Jump link has the params ref, like this: https://www.binance.com/cn/buy-sell-crypto?fiat=USD&crypto=BTC&amount=1000&ref=xxxxxx

install

npm install @binance/fiat-widget

// or cdn

<script src="https://public.bnbstatic.com/static/js/ocbs/@binance/fiat-widget.js"></script>

used

<div id="widget"></div>
import {Widget} from '@binance/fiat-widget'

const options = {
    locale: 'en',
    width: 200,
    theme: 'dark',
    coinInfo: {
      fiat: '',
      crypto: '',
      isInUS: false
    },
    urlParmas: {
        ref: '',
        us_ref: '',
        utm_source: ''
    }
}

Widget('#widget', options)
  • react
import {Widget, unloadWidget} from '@binance/fiat-widget'
const app = () => {
    const t = useRef<HTMLDivElement>(null)
    // or
    // const t = document.querySelector('#test')

    useEffect(() => {
        if (t) {
            Widget(t)
        }
        return () => unloadWidget()
    }, [])
    return (<div id="#test" ref={r}></div>)
}

Parameters

  • el: selector or DOM element

  • options.locale: string

    i18n, nullable, default: 'en'

    opts: 'cn','de','en','es','fr','id','it','kr','nl','pl','pt','ru','tr','tw','ua','vn',, unsupported locale will fallback to english

  • options.width: number

    width, nullable,

    if width is not set, default is el.offsetWidth

    range: 200 - 500

  • options.theme: string

    theme, nullable, default: 'light'

    opts: 'light' | 'dark'

  • options.urlParmas

    • options.urlParmas.ref: string

      ref id, nullable

    • options.urlParmas.us_ref: string

      Input your ref_id 1). If you have both Binance.com and Binance.US ref_id, please input your ref_id under 'ref and 'us_ref' section respectively 2). If you only have Binance.com ref_id, please input your ref_id under 'ref' and delete 'us_ref' section

      us_ref id, nullable

    • options.urlParmas.utm_source: string

      UTM source, nullable

  • options.coinInfo

    • options.coinInfo.fiat: string

      fiat name, nullable

    • options.coinInfo.crypto: string

      crypto name, nullable

    • options.coinInfo.isInUS: string

      For US Widget Partners (Eg. >50% of the website traffic is in US), please input true. USD - For US Residents will be the default fiat option. For International Widget Partners, please input false.

      opts: true | false

  • options.api_host: string

    overlay getCoinListApi, nullable

  • options.us_api_host: string

    overlay getUsCoinListApi, nullable

  • options.skeletonScreen: boolean

    nullable, default true, show a placeholder widget

API

  • setXXX

    setXXX is the function to change Widget's characters, you can use it by chaining likes jquery, and you need to use render to render it

const w = widget(container, opt)
w.setTheme('dark').setLocale('cn').render()
- setTheme

    change the theme
const w = widget(container, opt)
w.setTheme('dark').render()
- setLocale

    change the locale
const w = widget(container, opt)
w.setLocale('cn').render()
  • render

    render the widget (after .setXXX() is necessary)

const w = widget(container, opt)
w.setTheme('dark').render()
render will fetch api, so `render` return a `Promise`
const w = widget(container, opt)
w.setTheme('dark').render().then(v => alert('has render'))
  • unloadWidget

    remove the widget from page, maybe you will use it in React hooks to replace setXXX()

useEffect(() => {
  if (t?.current) {
      w = Widget(t.current, {
          theme: theme
      })
  }
  return () => unloadWidget()
}, [theme])

版本与发布记录

@binance/fiat-widget 共发布 32 个版本,首次发布于 2020/07/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.26latest2023/07/253 年前
1.1.252023/02/143 年前
0.0.0-dev.e0f3bbe2022/10/254 年前
0.0.0-dev.5fb14d42022/10/254 年前
1.1.242022/10/194 年前
1.1.232022/06/144 年前

关于 @binance/fiat-widget 的常见问题

@binance/fiat-widget 是什么?

You are not on any trade or economic sanctions lists, such as the UN Security Council Sanctions list, designated as a “Specially Designated National” by OFAC (Office of Foreign Assets Control of the U.S. Treasury Department) or placed on the U.S. Comme

如何安装 @binance/fiat-widget?

在项目目录运行 npm install @binance/fiat-widget,或使用 pnpm add / yarn add / bun add。

@binance/fiat-widget 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@binance/fiat-widget 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@binance/fiat-widget 可以商用吗?

@binance/fiat-widget 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@binance/fiat-widget 的下载量有多少?

根据 npm 官方下载统计,@binance/fiat-widget 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,531 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@binance/fiat-widget 还在维护吗?

最新版本 1.1.26 发布于 2023/07/25(3 年前);至今共发布 32 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/07/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。