Appearance
API
ViMi Labs provides API access for external applications that need to connect to a lab programmatically.
In this guide, we will cover:
- how to create API access in ViMi
- how lab scope works
- API basics
Create API Access
In ViMi Labs, go to Integration on the sidebar and go to menu item API Keys.
When creating the key:
- give it any label
- choose a scope; see the section about scopes for more details
- submit to create
- copy and save the token in a safe place
IMPORTANT
The token is shown only once. If you lose the token, you can regenerate a new one which immediately invalidates the old one.
IMPORTANT
API keys expire after 90 days of inactivity.
How Lab Scope Works
ViMi API access is always tied to a user and a lab context.
There are two key modes:
- open scope - the API key can be used for any lab the user currently has access to
- single-lab scope - the API key can only be used for its configured lab
In both cases, ViMi still checks whether the user currently belongs to the requested lab.
IMPORTANT
If the user loses access to a lab, the external application also loses access to that lab.
API Basics
Throughout the rest of the API reference guide, we will use the following variables:
sh
# bearer token
VIMI_API_TOKEN=
# canonical lab identifier - this is the value of the `code` attribute from the `labs` response
VIMI_LAB=
# base URL
VIMI_BASE_URL=https://apps.vimilabs.comAuthorization and Content-Type Headers
All API requests (unless otherwise stated) requires the bearer token.
Send it in the request headers:
http
Authorization: Bearer {VIMI_API_TOKEN}
Content-Type: application/jsonAll API communication should use JSON.
Lab-Scoped Routes
User-related API routes are reserved under:
text
api/v1/user/...Lab discovery is available under:
text
api/v1/labsLab-specific operations are reserved under:
text
api/v1/lab/{$VIMI_LAB}/...First Request
If you are not sure which labs are accessible, start with:
http
GET /api/v1/labs
Authorization: Bearer {VIMI_API_TOKEN}
Content-Type: application/jsonThis returns the labs the API key is currently allowed to access. See Labs API for more details.
