Let’s test out running Junction locally by cloning the Quickstart app.
To create a team and get your API keys, you first need to sign up for a Junction account in the Dashboard.Once registered, you can create a team by hovering over your username at the bottom of the Dashboard sidebar.
A team is associated with a region (either EU or US). The region dictates where data is stored.
You can learn more at regions.To create your API keys, go to the configuration section of the Dashboard.
For each region, you’ll have access to two environments: Sandbox and Production.
We’ll start in the Sandbox environment, so create a new Sandbox API key.
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@junction.com
Once you have your API keys, it’s time to run the Junction Quickstart locally!
The instructions below will guide you through the process of cloning the Quickstart repository,
customizing the .env file with your own Junction API_KEY and finally, building and running the app.
1. Clone quickstart and run locally
# Note: If on Windows, run# git clone -c core.symlinks=true https://github.com/tryVital/quickstart# instead to ensure correct symlink behaviorgit clone https://github.com/tryVital/quickstart.git# Create .env, then fill# out VITAL_API_KEY, VITAL_REGION (eu, us) and VITAL_ENV in .envtouch .env# Note: must use python 3# For virtualenv users:# virtualenv venv# source venv/bin/activatepoetry install# Start the backend appcd backend/pythonsource ./start.sh
Open a new shell and start the frontend app. Your app will be running at http://localhost:3000.
2. Run quickstart frontend
# Install dependenciescd quickstart/frontendnpm install# Open .env.local, then fill# out NEXT_PUBLIC_VITAL_API_KEY, NEXT_PUBLIC_VITAL_ENV and NEXT_PUBLIC_VITAL_REGION# Start the frontend appnpm run dev# Go to http://localhost:3000
When retrieving data or connecting devices, Junction will require a user_id as input.
A user_id is a unique representation that we hold for a user. It allows you to fetch data for that user.
To create a user, you need to pass a unique id (client_user_id). This represents the user in your system. Our recommendation is
to store the Junction user_id in your db against the user row.
Personally identifiable information (PII), such as an email address or phone number, should not be used as input for the client_user_id parameter.
Enter a new client_user_id and tap Create:This can also be achieved via the API as follows.
A source, at Junction, is a medical device, wearable, or lab. It is a source of information for health data.
To connect a source, tap the connect button. This will launch the Junction Link Widget for that user.Once you have entered your credentials and moved to the next screen, you have connected your first source!
You can now make API calls to retrieve data for that Source.
As you might have noticed, you use both a server and a client-side component to access the Junction APIs.
A more detailed explanation of how linking works can be found in link flow.The first step is to create a new link_token by making a /link/token request and passing in the
required configuration. This link_token is a short-lived, one-time use token that authenticates your
app with Junction Link, our frontend module.
Once you have a link_token, you can use it to initialize Link. Link is a drop-in client-side
module available for web, iOS, and Android that handles the authentication process.
The Quickstart uses Link on the web, which is a pure JavaScript integration that you trigger via your own client-side code.
We can now explore what happens when
you press the analyze 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
summary data for a user. The request is simple and requires the Junction
user_id, start_date and end_date.Getting user sleep data
Congratulations, you have completed the Junction Quickstart!There are a few directions you can go in now:
Junction Link
A client-side component your users will interact with in order to link their
accounts with Junction. It allows you to access their accounts via the Junction API.
Junction SDKs
Native toolkits to integrate Junction into iOS, Android, and Flutter
Junction Webhooks
Webhooks are a way to receive data from Junction. We frequently poll to receive
data from the various providers.