Skip to main content

Introduction

Let's get started, first you’ll need API keys, which you can request by registering with us in the Dashboard.

Once registered, you will be granted access to: the Dashboard, our Sandbox and Production environments, and be given a unique API key for each environment.

Keys
api_key
Private identifier for your team
Environment
sandbox
Integration Testing
production
Live environment to use with real customers
API Urls
production
https://api.tryvital.io
production-eu
https://api.eu.tryvital.io
sandbox
https://api.sandbox.tryvital.io
sandbox-eu
https://api.sandbox.eu.tryvital.io

Example API collection can be downloaded from here or by installing postman first and clicking on the below button.

Run in Postman


info

If you get stuck at any point in the Quickstart, help is just a click away! Join our Slack channel or send us a message to support@tryvital.io

Quickstart Setup​

We offer different SDKs so you can start building your app right away.

vital-pythonPython library for calling Vital API on your backend
vital-linkReact Library for initializing link
vital-nodeVital Node Client
JavaSoon to be added
GoSoon to be added

Creating Your First User​

Once you have your API Keys you are ready to create your first user!

Almost all API requests will interact with a user. To allow a user to connect to the API, first create a user_id using the /user/ endpoint. A user_id is the unique key we use to lookup users in our database. This should be a unique ID generated from your application - upon user sign up.

caution

Personally identifiable information (PII), such as an email address or phone number, should not be used as input for the user_id parameter.



post

/v2/user/

Request fields and example

No parameters

Create a Vital User
1
2
3
4
5
6
7
8
9
10
11
curl --request POST \
     --url https://api.tryvital.io/v2/user/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --data '
{
     "client_user_id": "string",
     "team_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
     "id": "string"
}
'
Response fields and example

No parameters

Response
1

How it works​

As you might have noticed, you use both a server and a client-side component to access Vital APIs. The flow looks like this:

The Vital flow begins when your user wants to connect their device to your application.

  1. To launch Vital link, first generate a `link_token` by passing the `user_id` to the `/link/token` endpoint.
  2. Pass the `link_token` into the Vital link component to open the link for the user. Please note: the `link_token` is a short-lived one-time use token.
  3. Use the onSuccess, onError, onExit callbacks to handle different events on your frontend.

Making API requests​

Now that we've gone over the Link flow and token exchange process, we can explore what happens when you press a button in the Quickstart to make an API call. As an example, we'll look at the Quickstart's call to /summary/sleep, which retrieves sleep information for a user. The call is fairly straightforward and uses the start_date and end_date as arguments to the Vital client object.


Getting User sleep data
1
2
3
4
5
6
7
8
9
from vital import Client

client = Client(
  api_key=<API_KEY>,
  environment="sandbox",
  region="us"
)

sleep_data = client.Sleep.get(start_date, end_date)

Next Steps​

Congratulations, you have completed the Vital Quickstart! From here, we invite you to modify the Quickstart code in order to get more practice with the Vital API.

There are a few directions you can go in now: