Using our API

Manually generate a graph and customise some settings using our api in less than 5 minutes!

By the end of this guide users will be able to integrate their app with a graph of their data. The steps are:

  1. Obtain developer credentials from dashboard
  2. Create a graph session using the credentials and necessary settings for graphs
  3. Create a url using the session id, combined with user id and time settings

1) Obtain developer credentials from dashboard

2) Create a graph session

Create a post request using the InitializeGraphSession endpoint. Look at appendix to view different types of graphs to use and customisations available.

curl --request POST \
     --url https://api.tryterra.co/v2/graphs/ \
     --header 'dev-id: <YOUR DEV ID>' \
     --header 'x-api-key: <YOUR API KEY>' \
     --data '
{
  "type": "SLEEP_HR_SUMMARY",
  "bgcolor": "FFFFFF",
  "linecolor": "FFF000"
}
'

3) Create and visit a url which contains the graph

Using the generated session ID, a user id and a specified timeframe in the ViewGraphSession endpoint, the visited url will contain the desired graph.

curl --request GET \
     --url https://api.tryterra.co/v2/graphs/<YOUR SESSION ID>/<YOUR USER ID>/ \
     --d 'timeframe=10' \
     --d 'from=2023-01-01' \
     --d 'to=2023-01-01'

For the time range, timeframe will be prioritised. If timeframe is not present from and to will be used to determine the date ranges. If to is not present it will default to today's date.

Appendix

Graph Types

Activity

  • ACTIVITY_HR_SAMPLES: BPM vs Timestamp
  • ACTIVITY_POWER_SAMPLES: Watts vs Timestamp

Body

  • BODY_GLUCOSE_SUMMARY: Average blood glucose (mg/dL) vs Date
  • BODY_GLUCOSE_AGP: Ambulatory Glucose Profile
  • BODY_GLUCOSE_SAMPLES: Blood glucose samples (mg/dL) within a day over a 24h axis

Daily

  • DAILY_STEPS_SUMMARY: Daily walking step vs Date
  • DAILY_RHR_SUMMARY: Daily resting heart rate vs Date

Sleep

  • SLEEP_ASLEEP_SUMMARY: Daily asleep time vs Date
  • SLEEP_HR_SUMMARY: Daily average sleeping heart rate vs Date
  • SLEEP_HRV_SDNN_SUMMARY: Daily average sleeping heart rate variability based on SDNN value vs Date
  • SLEEP_HRV_RMSSD_SUMMARY || SLEEP_HRV_SUMMARY: Daily average sleeping heart rate variability based on RMSSD value vs Date
  • SLEEP_RHR_SUMMARY: Resting heart rate vs Date
  • SLEEP_RESPIRATORY_RATE_SUMMARY: Respiratory rate (breaths per minute) vs Date
  • SLEEP_REM_SUMMARY: REM sleep duration vs Date
  • SLEEP_LIGHT_SUMMARY: Light sleep duration vs Date
  • SLEEP_DEEP_SUMMARY: Deep sleep duration vs Date

Graph Customisation Options

  • bgcolor: Sets the background color of the graph.
  • textcolor: Defines the color of the text displayed within the graph.
  • linecolor: Specifies the color of the lines in the graph.
  • unselectedcolor: Determines the color of unselected elements in the graph.
  • charttype: Specifies the type of chart to be rendered (e.g., bar, line).
  • start_date: Defines the starting date for the data range displayed in the graph.
  • end_date: Sets the ending date for the data range displayed in the graph.
  • timeperiod: Determines the time period represented in the graph.
  • y_max: Sets the maximum value for the Y-axis.
  • y_min: Defines the minimum value for the Y-axis.
  • enable_y_axis_unit: If true, the units of measurement for the Y-axis will be displayed.
  • indicator2Y: Specifies the second indicator on the Y-axis.
  • indicator1Y: Specifies the first indicator on the Y-axis.
  • font: Defines the font used for text within the graph.
  • height: Sets the height of the graph.
  • width: Defines the width of the graph.
  • legend: If true, a legend will be displayed on the graph.
  • img_width: Specifies the width of the image in the graph.
  • img_height: Determines the height of the image in the graph.
  • get_img: If true, retrieves the image for the graph.
  • colorPanelList: Defines the list of colors for the panels in the graph.
  • colorHoverPanelList: Specifies the list of hover colors for the panels in the graph.
  • labelFontSize: Sets the font size of the labels in the graph.
  • window_size: Determines the size of the window displaying the graph.
  • dragging: If true, enables dragging functionality within the graph.
  • scrolling: If true, enables scrolling functionality within the graph.
  • enable_header: If true, displays a header in the graph.
  • enable_footer: If true, displays a footer in the graph.
  • display_value_bottom: If true, values will be displayed at the bottom of the graph.
  • enable_html_time_period: If true, allows for the use of HTML in the time period display.
  • enable_html_title: If true, allows for the use of HTML in the title of the graph.
  • html_title_content: Specifies the HTML content for the title of the graph.
  • html_time_period_content: Specifies the HTML content for the time period display.
  • enable_aspect_ratio: If true, maintains the aspect ratio of the graph.
  • get_react_native: If true, retrieves the React Native component for the graph.
  • get_small_template: If true, retrieves a smaller template for the graph.
  • fixed_time_axis: If true, the time axis of the graph will be fixed.