Skip to main content

Wait Times API

An API for retrieving facility wait time estimates.

We offer average facility "Registration to Treatment Area" wait estimates on a per-facility basis.

Previously, wait times were only available in-app. The Wait Times API allows facilities to make API calls and receive our wait time estimates directly, for use in their own systems, for example, websites or TV displays, to better communicate wait times to patients and staff. These wait times are not patient-specific.

Overview

  • Using the endpoint below, the estimated wait time can be retrieved by Facility ID.

  • This returns the lower and upper bound estimates for the length of time for a patient to move from registration to treatment area at a specific facility.

  • The lower and upper bound estimates represent the 50th and 90th quantiles of our wait time estimates.

  • The lower and upper bound estimates are rounded up to the nearest 5 minutes, to match the wait time estimates shown in Vital Emergency.

  • Wait time estimates are cached for 24 hours.

API endpoint

https://api.vital.io/graphql

Required IDs

You will require the following IDs to use this endpoint (these will be provided to you by Vital):

  • facility-id

  • client-id

  • client-secret

Authentication

We use the Client Credentials Flow for authentication and authorization.

  1. Your Client ID and Client Secret will be provided to you by the Vital team.

  2. Your application sends your credentials (Client ID and Client Secret) to the Auth0 Authorization Server.

  3. The Auth0 Authorization Server validates your application's credentials and responds with an access token.

  4. Your application can then use the access token to call the API, which will respond with the requested data.

Exchanging client credentials for an access token

You can execute a client credentials exchange to get an access_token to query the Wait Times API. Here are a few examples in different languages.

cURL

curl --request POST \
  --url https://vital-software.us.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{"client_id":"","client_secret":"","audience":"https://api.vital.io","grant_type":"client_credentials"}'

Node.js

const response = await fetch('https://vital-software.us.auth0.com/oauth/token', {
  method: 'POST',
  body: new URLSearchParams({
    grant_type: 'client_credentials',
    audience: 'https://api.vital.io',
    client_id: '',
    client_secret: '',
  }),
})
console.log(await response.text())

Response

You'll receive an HTTP 200 response with a payload containing access_token and token_type values:

{
  "access_token": "eyJz93a...k4laUWw",
  "expires_in": 86400,
  "token_type": "Bearer"
}

API request/response

Wait Times API request

You can then use this access_token with an Authorization header in your request to obtain authorized access to the Wait Times API. Below are examples using Node.js and GraphQL directly.

Node.js

const response = await fetch('https://api.vital.io/graphql', {
  method: 'POST',
  headers: {
    'content-type': 'application/json',
    authorization: '',
  },
  body: JSON.stringify({
    query: `query Facility($id: String!) { facility(id: $id) { id waitTimes { registrationToTreatmentArea { estimatedLowerBoundMinutes estimatedUpperBoundMinutes } } } }`,
    variables: { id: '' },
  }),
})
console.log(await response.text())

GraphQL

Query:

query Facility($id: String!) {
  facility(id: $id) {
    id
    waitTimes {
      registrationToTreatmentArea {
        estimatedLowerBoundMinutes
        estimatedUpperBoundMinutes
      }
    }
  }
}

Query variables:

{
  "id": ""
}

HTTP headers:

{
  "authorization": ""
}

Wait Times API response

You will receive a response with the wait times data in the following format:

{
  "data": {
    "facility": {
      "id": "",
      "waitTimes": {
        "registrationToTreatmentArea": {
          "estimatedLowerBoundMinutes": 25,
          "estimatedUpperBoundMinutes": 90
        }
      }
    }
  }
}

Did this answer your question?