LNbits API is built using
FastAPI, a high-performance, easy to code API framework.
FastAPI auto-generates swagger UI docs for testing endpoints
/docs
views.py
is used for
setting application routes:
views_api.py
is used
for setting application API endpoints:LNbits uses Quasar Framework for frontend deisgn elements. Quasar Framework is an open-source Vue.js based framework for building apps.
TIP: Look through/template
files in
other extensions for examples of Quasar elements being used.
In the below example we make a dialogue popup box (box can
be triggered
LNbits uses Vue for best-in-class, responsive and high-performance components.
Typical example of Vue components in a frontend script:
Content can be conditionally rendered using Vue's
v-if
:
A magical "g" (ie
this.g.user.wallets[0].inkey
) is always available, with info about the user, wallets
and extensions:
{% raw %}{{ g }}{% endraw %}
LNbits includes a handy exchange rate function, that streams rates from 6 different sources.
Exchange rate API:from lnbits.utils.exchange_rates import
fiat_amount_as_satoshis
:For most purposes use Quasar's inbuilt VueQrcode library:
LNbits does also include a handy QR code enpoint
{% raw %} You can use via {{protocol + location}}{% endraw %}/api/v1/qrcode/some-data-you-want-in-a-qrcode:Fastapi includes a great websocket tool
{% raw %}
A few LNbits extensions also make use of a weird and useful
websocket/GET tool built into LNbits, such as extensions
Copilot and LNURLDevices
You can subscribe to websocket with
wss:{{location}}/api/v1/ws/{SOME-ID}
You can post to any clients subscribed to the endpoint with
{{protocol +
location}}/api/v1/ws/{SOME-ID}/{THE-DATA-YOU-WANT-TO-POST}
Function used in this demo: