A minimal web app (in app/
) that shows how to interact with the Nabla Core API.
- Node.js v22+
- A Nabla Core API account (contact us to create one)
git clone [email protected]:nabla/sample-app.git
cd sample-app/
npm install
- Sign in to the Core API admin console: Log in.
- Follow the documentation to create a new OAuth Client with the "Public Key (static)" method.
You need to use this OAuth client to generate initial user access and refresh tokens for the app. In a realistic architecture, this work would be done by a dedicated authentication backend server on your side. For simplicity's sake, however, we provide an helper node script that imitates a backend server that would create and authenticate a Core API user.
This script is located under scripts/generate-tokens.js
and expects the following CLI required arguments:
--uuid
(type:string
): the OAuth client UUID for authentication--private-key
(type:string
): the path to the private key file (generallyprivate_key.pem
if you followed the documentation closely at the previous step)--hostname
(type:string
): Nabla's API hostname:us.api.nabla.com
for US region oreu.api.nabla.com
for EU region.
Run the following command to generate a pair of user access/refresh tokens:
node scripts/generate-tokens.js \
--uuid=<oauth-uuid> \
--private-key=<private-key-file> \
--hostname=us.api.nabla.com
ℹ️ Need a server token instead? Pass the
--type=server
argument to the command above to generate a long-lived server access token rather than user access/refresh tokens. Use this when calling the Server API directly from your own tools.
To launch the app, the following environment variables need to be set:
VITE_NABLA_ACCESS_TOKEN
: a user access tokenVITE_NABLA_REFRESH_TOKEN
: a user refresh tokenVITE_NABLA_API_HOSTNAME
: Nabla's API hostname:us.api.nabla.com
for US region oreu.api.nabla.com
for EU region.
Create a .env.local
file at the root of the project, and add the credentials generated in Step 3 (or any other source you use):
VITE_NABLA_ACCESS_TOKEN=my_user_access_token
VITE_NABLA_REFRESH_TOKEN=my_user_refresh_token
VITE_NABLA_API_HOSTNAME=us.api.nabla.com
Run the following command and navigate to http://localhost:5173/
npm run dev
Note
API version notice
Please note that this sample app is only compatible with a specific version of the API, specified at the beginning of the commonUtils.js file.
- Authentication guide: https://docs.nabla.com/guides/authentication
- Full API docs: https://docs.nabla.com