Python Client

Source code: https://github.com/tryterra/terra-client-python

class Terra

An object that manages getting data, verifying signatures and authenticating users

Initialisation

from terra.base_client import Terra

terra = Terra(api_key: str, dev_id: str, secret: str)

Instance Variables

Instance Variable NameReturnsExplanation
api_keystrreturns the api_kay the class was initiated with
dev_idstrreturns the dev_id the class was initiated with
secretstrreturns the secret the class was initiated with

Methods

Method NameReturnsExplanation
get_activity_for_userTerraApiResponsereturns an api response that when parsed contains activity data
get_athlete_for_userTerraApiResponsereturns an api response that when parsed contains athlete data
get_body_for_userTerraApiResponsereturns an api response that when parsed contains body data
get_daily_for_userTerraApiResponsereturns an api response that when parsed contains daily data
get_menstruation_for_userTerraApiResponsereturns an api response that when parsed contains menstruation data
get_nutrition_for_userTerraApiResponsereturns an api response that when parsed contains nutrition data
get_sleep_for_userTerraApiResponsereturns an api response that when parsed contains sleep data
get_user_infoTerraApiResponsereturns an api response that when parsed contains user data
list_providersTerraApiResponsereturns an api response that when parsed contains one list for web providers and another for sdk providers
list_usersTerraApiResponsereturns an api response that when parsed contains a list of all users
check_terra_signatureboolreturns whether the body was sent from Terra
handle_flask_webhookTerraWebhookResponsereturns either data or None type if check_terra_signature failed, specifically for flask
handle_webhookTerraWebhookResponse returns a webhook response objectreturns either data or None type if check_terra_signature failed
deauthenticate_userTerraApiResponsereturns an api response object that when parsed returns a
generate_authentication_urlTerraApiResponsereturns an api response that when parsed contains details about an authentication session with one provider
generate_widget_sessionTerraApiResponsereturns an api response that when parsed contains details about an authentication session with one of the inputted providers
from_user_idUserreturns a User object from user_id

Parsed Webhook Response Types

DataReturned

DataReturned(user: User, type: str, data: List[TerraDataModel])

NoDataReturned

NoDataReturned(user: User, status: str, message: str)

AccessRevokedHookResponse

AccessRevokedHookResponse(user: User, message: str)

AuthHookResponse

AuthHookResponse(reference_id: str, user: User, widget_session_id: str)

UserReauthHookResponse

UserReauthHookResponse(old_user: User, new_user: User, message: str)

UserDeauthHookResponse

UserDeauthHookResponse(user: User, message: str)

ConnectionErrorHookResponse

ConnectionErrorHookResponse(user: User, message: str)

GoogleNoDataSourceHookResponse

GoogleNoDataSourceHookResponse(user: User, message: str)

RequestProcessingHookResponse

RequestProcessingHookResponse(user: User, message: str)

RequestCompletedHookResponse

RequestCompletedHookResponse(user: User, message: str)