BCV rate widget

Show today's official BCV rate on any website with one line of code, for free.

The data is published under CC BY 4.0: if you show it, credit the source.

Configure it

The configurator needs JavaScript. Here is the basic code: paste it into your page and adjust the attributes with the reference below.

Code for your page

<script type="module" src="https://bcv.today/widget/v1.js"></script>
<bcv-rate></bcv-rate>

Add the <script> tag only once per page, even if you use several widgets.

Reference

Attributes

All of them can be changed at any time and the widget updates.

AttributeValuesDefault
currencyUSD, EUR, CNY, TRY, RUBUSD
variantcard, line (inline pill inside a sentence), converter (amount input to bolivars)card
langes, enThe closest lang attribute on the page (en* is English), else es
themeauto (follows prefers-color-scheme), light, darkauto
amountThe converter's initial amount, a plain number such as 100 or 1234.51
hide-sourceBoolean: hides the "Source: BCV Today" linkShown
apiData origin, for tests or a mirrorhttps://bcv.today

Numbers follow the language: Spanish uses the Venezuelan format (916,6477, 1.007,3867), English the US format (916.6477, 1,007.3867). Rates have 4 decimals and converted amounts 2. The converter accepts amounts such as 1.234,5 or 1234.5.

CSS custom properties

Set them on the element or any ancestor. --bcv-bg and --bcv-text replace both the light and the dark value, so choose a pair with enough contrast or set them per theme.

PropertyDefault (light / dark)
--bcv-accent#f2b33d, the gold of the BCV Today mark (logo and focused input border)
--bcv-bg#fdfbf7 / #1c1a18
--bcv-text#1f1b16 / #efe9de
--bcv-radius12px (card and converter); the inline pill is fully rounded unless set
--bcv-fontSystem UI font (the inline variant inherits the surrounding font); numbers are always monospace

Parts (::part())

The widget uses Shadow DOM: your CSS does not leak in and its CSS does not leak out. To style specific pieces use bcv-rate::part(name) with these parts: container, label, value, change, date, note (cached notice), source, mark, status (loading and error text) and, in the converter, input and result.

bcv-rate {
  --bcv-radius: 4px;
  --bcv-font: "Inter", sans-serif;
}
bcv-rate::part(value) {
  font-weight: 700;
}

Events

The widget does not fire events of its own. In the converter, the amount field is a regular <input> inside the Shadow DOM.

Good to know

  • No cookies, no tracking. It only keeps the last good rate in the browser's localStorage, to show it when the API is unreachable (with a "Cached value" notice).
  • Reads public data only. It requests https://bcv.today/api/v1/rate.json and the daily history files to work out the change. Every widget on the page shares the same requests, refreshed every 30 minutes while the page is visible.
  • Works with a strict CSP. The markup is built with DOM APIs, never by parsing HTML, so script-src https://bcv.today and connect-src https://bcv.today are enough; it also works with Trusted Types.
  • Small. About 5 KB min+gzip, with no dependencies.
  • Accessible. Real text (no images of numbers), an accessible name such as "BCV rate: US dollar (USD)", the change direction spelled out for screen readers and a contrast of at least 4.5:1 in both themes.

Other ways to use the rate: all integrations and the API documentation. Widget source code on GitHub.