### Get Current User Overview - Shell Source: https://developer.exist.io/deprecated/v1 Fetches the current day's overview for the authenticated user using a shell command. This `curl` example demonstrates how to make a GET request to the `$self/today/` endpoint, requiring an API token for authentication. It returns user activity data for the current day. ```shell curl -H "Authorization: Token YOUR_API_TOKEN" https://exist.io/api/1/users/$self/today/ ``` -------------------------------- ### Get Specific Attribute Values (Response Example) Source: https://developer.exist.io/reference/attributes Example response for retrieving values of a specific attribute. It includes the total count of values, links for pagination, and a list of 'date' and 'value' objects, representing the recorded data points for the attribute over time. Results can be filtered by date. ```json { "count": 3217, "next": "https://exist.io/api/2/attributes/values/?attribute=steps&page=2", "previous": null, "results": [ { "date": "2022-05-13", "value": 1765 }, { "date": "2022-05-12", "value": 6792 }, { "date": "2022-05-11", "value": 4632 }, { "date": "2022-05-10", "value": 2121 }, { "date": "2022-05-09", "value": 5141 }, // ...snip!... ] } ``` -------------------------------- ### Get Specific Attribute Values (API Request Examples) Source: https://developer.exist.io/reference/attributes Fetches a paginated list of values for a specific attribute. Requires the attribute name and an authorization token. Supports filtering by limit, page, and a maximum date. The response provides the total count, navigation links, and a list of date/value pairs for the attribute. ```shell curl "https://exist.io/api/2/attributes/values/?attribute=[name]" -H "Authorization: Bearer [token]" ``` ```python import requests requests.get("https://exist.io/api/2/attributes/values/", params={"attribute": "[name]"}, headers={'Authorization': 'Bearer [token]'}) ``` -------------------------------- ### Python: Handle HTTP GET for Authorization Code and Exchange for Token Source: https://developer.exist.io/guide/write_client This Python code defines a handler for HTTP GET requests to receive an authorization code from the browser, parses the code from the URL query parameters, sends a POST request to the Exist.io API to exchange the code for an access token, and prints the received tokens. It requires the `requests` library and assumes `CLIENT_ID`, `CLIENT_SECRET`, and `REDIRECT_URI` are defined. ```python from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import urlparse, parse_qs import requests # Assume these are defined elsewhere # CLIENT_ID = 'your_client_id' # CLIENT_SECRET = 'your_client_secret' # REDIRECT_URI = 'http://localhost:8000/' class Handler(BaseHTTPRequestHandler): def do_GET(self): # parse the path of this request into its parts parts = urlparse(self.path) # then parse the query parameters into a dict query = parse_qs(parts.query) # and then get the code we need out of the dict code = query['code'][0] # tell the browser it worked self.send_response(200) self.wfile.write(b'OK!\n') # then get our access token self.get_token(code) def get_token(self, code): # make our request using our new code, and some other client details response = requests.post('https://exist.io/oauth2/access_token', { 'grant_type':'authorization_code', 'code': code, 'client_id': CLIENT_ID, 'client_secret': CLIENT_SECRET, 'redirect_uri': REDIRECT_URI, }) # parse the response into json data = response.json() print('Access token: ', data['access_token']) print('Refresh token:', data['refresh_token']) # create a http server and listen for one request only server_address = ('127.0.0.1', 8000) httpd = HTTPServer(server_address, Handler) httpd.handle_request() httpd.server_close() ``` -------------------------------- ### Get Current User Overview - Python Source: https://developer.exist.io/deprecated/v1 Fetches the current day's overview for the authenticated user. This Python function utilizes the 'requests' library to send a GET request to the user's today endpoint. It requires an API token for authentication and returns user activity data for the current day. ```python import requests def get_current_user_overview(): url = "https://exist.io/api/1/users/$self/today/" headers = { "Authorization": "Token YOUR_API_TOKEN" } response = requests.get(url, headers=headers) if response.status_code == 200: return response.json() else: print(f"Error: {response.status_code}") return None # Example usage: # today_overview = get_current_user_overview() # if today_overview: # print(today_overview) ``` -------------------------------- ### Get User Profile Stub - Shell Source: https://developer.exist.io/deprecated/v1 Retrieves a basic profile stub for a specified user using a shell command. This example demonstrates how to make a GET request to the API endpoint for user profiles using `curl`. It requires the user's ID or username and an authentication token. ```shell curl -H "Authorization: Token YOUR_API_TOKEN" https://exist.io/api/1/users/josh/ ``` -------------------------------- ### Users - Get Current Overview Source: https://developer.exist.io/deprecated/v1 Retrieves the current day's overview for a specified user, providing a summary of their daily activity. ```APIDOC ## Get Current Overview for User ### Description Fetches the current day's overview for a specified user, summarizing their activities and data for the day. ### Method GET ### Endpoint `/api/1/users/$self/today/` ### Parameters #### Query Parameters - **username** (string) - Required - The username of the user or `$self` for the authenticated user. ### Response #### Success Response (200) This endpoint returns a detailed JSON object with the user's data for the current day. The exact structure may vary based on available data points. ``` -------------------------------- ### GET /api/1/users/:username/profile/ Source: https://developer.exist.io/deprecated/v1 Retrieves a user profile stub, providing an overview of the user's personal details. ```APIDOC ## GET /api/1/users/:username/profile/ ### Description Returns an overview of the user’s personal details. ### Method GET ### Endpoint /api/1/users/:username/profile/ ### Parameters #### Path Parameters - **username** (string) - Required - The username of the user to retrieve the profile for. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -H "Authorization: Bearer [YOUR_ACCESS_TOKEN]" https://exist.io/api/1/users/$self/profile/ ``` ### Response #### Success Response (200) - **id** (integer) - The user's unique identifier. - **username** (string) - The user's username. - **first_name** (string) - The user's first name. - **last_name** (string) - The user's last name. - **bio** (string) - A short biography of the user. - **url** (string) - The user's personal website URL. - **avatar** (string) - The URL of the user's avatar image. - **timezone** (string) - The user's timezone. - **local_time** (string) - The current local time for the user in ISO 8601 format. - **private** (boolean) - Indicates if the user's profile is private. - **imperial_units** (boolean) - Indicates if the user prefers imperial units for general measurements. - **imperial_distance** (boolean) - Indicates if the user prefers imperial units for distance. - **imperial_weight** (boolean) - Indicates if the user prefers imperial units for weight. - **imperial_energy** (boolean) - Indicates if the user prefers imperial units for energy. - **imperial_liquid** (boolean) - Indicates if the user prefers imperial units for liquid volume. - **imperial_temperature** (boolean) - Indicates if the user prefers imperial units for temperature. - **attributes** (array) - A list of attribute groups associated with the user (usually empty for profile stub). #### Response Example ```json { "id": 1, "username": "josh", "first_name": "Josh", "last_name": "Sharp", "bio": "I made this thing you're using.", "url": "http://hellocode.co/", "avatar": "https://exist.io/static/media/avatars/josh_2.png", "timezone": "Australia/Melbourne", "local_time": "2020-07-31T22:33:49.359+10:00", "private": false, "imperial_units": false, "imperial_distance": false, "imperial_weight": false, "imperial_energy": false, "imperial_liquid": false, "imperial_temperature": false, "attributes": [] } ``` ``` -------------------------------- ### Attributes - Get Multiple Source: https://developer.exist.io/deprecated/v1 Retrieves a list of multiple attributes, allowing you to fetch information about several attributes in a single request. ```APIDOC ## Get Multiple Attributes ### Description Retrieves information for multiple attributes. This endpoint allows fetching data for several attributes efficiently in one call. ### Method GET ### Endpoint `/api/1/attributes/` ### Parameters #### Query Parameters - **slug** (string) - Optional - A comma-separated list of attribute slugs to retrieve. ### Response #### Success Response (200) Returns a list of attribute objects, each containing details about a specific attribute. ``` -------------------------------- ### GET /api/2/accounts/profile/ Source: https://developer.exist.io/reference/users Retrieves basic details and personal preferences for the authenticated user. No specific scope is required for this endpoint. ```APIDOC ## GET /api/2/accounts/profile/ ### Description Returns some basic details and personal preferences for the authenticated user. No specific scope is required. ### Method GET ### Endpoint /api/2/accounts/profile/ ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```shell curl "https://exist.io/api/2/accounts/profile/" -H "Authorization: Bearer [YOUR_TOKEN]" ``` ```python import requests requests.get("https://exist.io/api/2/accounts/profile/", \ headers={'Authorization':'Bearer [YOUR_TOKEN]'}) \ ``` ### Response #### Success Response (200) Returns a user object in JSON: - **username** (string) - The user's username. - **first_name** (string) - The user's first name. - **last_name** (string) - The user's last name. - **avatar** (string) - URL to the user's avatar. - **timezone** (string) - The user's timezone. - **local_time** (string) - The user's local time. - **imperial_distance** (boolean) - Indicates if imperial units are used for distance. - **imperial_weight** (boolean) - Indicates if imperial units are used for weight. - **imperial_energy** (boolean) - Indicates if imperial units are used for energy. - **imperial_liquid** (boolean) - Indicates if imperial units are used for liquid measurements. - **imperial_temperature** (boolean) - Indicates if imperial units are used for temperature. - **trial** (boolean) - Indicates if the user is on a trial period. - **delinquent** (boolean) - Indicates if the user's account is delinquent. #### Response Example ```json { "username": "josh", "first_name": "Josh", "last_name": "Sharp", "avatar": "https://exist.io/media/avatars/josh.png", "timezone": "Australia/Sydney", "local_time": "2022-05-16T16:01:37.587301+10:00", "imperial_distance": false, "imperial_weight": false, "imperial_energy": false, "imperial_liquid": false, "imperial_temperature": false, "trial": false, "delinquent": false } ``` ``` -------------------------------- ### Receive Authorisation Callback (Python) Source: https://developer.exist.io/guide/write_client Sets up a basic HTTP server to receive the callback from the Exist authorisation page after a user grants permissions. This script defines placeholder variables for CLIENT_ID, CLIENT_SECRET, and REDIRECT_URI. It's intended to be the server-side component that handles the redirect and captures the authorisation code. ```python from http.server import HTTPServer, BaseHTTPRequestHandler from urllib.parse import urlparse, parse_qs import requests CLIENT_ID = '' CLIENT_SECRET = '' REDIRECT_URI = 'http://localhost:8000/' ``` -------------------------------- ### Initiate OAuth2 Authorization Flow Source: https://developer.exist.io/deprecated/v1 This code snippet demonstrates how to redirect a user to the Exist.io authorization page. It constructs the URL with necessary parameters like client ID, redirect URI, and requested scopes. ```shell # We can't really do this from the shell, but your URL would look like this: curl https://exist.io/oauth2/authorize?response_type=code&client_id=[your_id]&redirect_uri=[your_uri]&scope=[your_scope] ``` ```python # in django, we would do something like this return redirect('https://exist.io/oauth2/authorize?response_type=code&client_id=%s&redirect_uri=%s&scope=%s' % (CLIENT_ID, REDIRECT_URI,"read+write")) ``` -------------------------------- ### Fetch Attributes with Authentication and Pretty Printing (Python) Source: https://developer.exist.io/guide/read_client This snippet demonstrates how to make a GET request to the exist.io API, including an Authorization header with a token. It then checks the response status, parses the JSON data, and uses the `pprint` module for human-readable output of nested data structures. It also explains the structure of the paginated JSON response. ```python import requests from pprint import pprint url = 'https://exist.io/api/2/attributes/with-values/' TOKEN = 'YOUR_TOKEN_HERE' # Replace with your actual token response = requests.get(url, headers={'Authorization': f'Token {TOKEN}'}) if response.status_code == 200: data = response.json() pprint(data) else: print("Error!", response.content) ``` -------------------------------- ### GET /api/2/attributes/templates/ Source: https://developer.exist.io/reference/attributes Retrieve a list of all attribute templates supported by Exist. This includes details about each attribute's name, label, group, priority, and value type. ```APIDOC ## Get attribute templates ### Description Retrieve a list of the attribute templates Exist supports. See attribute template definition and list. ### Method GET ### Endpoint /api/2/attributes/templates/ ### Parameters #### Query Parameters - **page** (integer) - Optional - Page index. Defaults to 1. - **limit** (integer) - Optional - Defines how many results to return per page. - **include_low_priority** (boolean) - Optional - Set to `true` to include attributes with a `priority` >= 10. - **groups** (string) - Optional - Comma-separated list of groups to filter by, e.g. `activity,workouts`. ### Response #### Success Response (200) A paged list of attribute template objects. - **count** (integer) - The total number of attribute templates available. - **next** (string) - URL for the next page of results, or null if none. - **previous** (string) - URL for the previous page of results, or null if none. - **results** (array) - An array of attribute template objects. - **name** (string) - The unique name of the attribute template. - **label** (string) - The human-readable label for the attribute. - **group** (object) - Information about the group the attribute belongs to. - **name** (string) - The name of the group. - **label** (string) - The label of the group. - **priority** (integer) - The priority of the group. - **priority** (integer) - The priority of the attribute. - **value_type** (integer) - A numerical code representing the type of value the attribute holds. - **value_type_description** (string) - A description of the value type (e.g., "Integer", "Period (min)"). ### Request Example ``` GET https://exist.io/api/2/attributes/templates/ Authorization: Bearer [token] ``` ### Response Example ```json { "count": 81, "next": "https://exist.io/api/2/attributes/templates/?page=2", "previous": null, "results": [ { "name": "steps", "label": "Steps", "group": { "name": "activity", "label": "Activity", "priority": 1 }, "priority": 1, "value_type": 0, "value_type_description": "Integer" }, { "name": "steps_active_min", "label": "Active minutes", "group": { "name": "activity", "label": "Activity", "priority": 1 }, "priority": 2, "value_type": 3, "value_type_description": "Period (min)" } ] } ``` ``` -------------------------------- ### Get Insights List - Shell Source: https://developer.exist.io/reference/insights Retrieves a paged list of the authenticated user's insights using a GET request. Requires an Authorization header with a Bearer token. Supports optional query parameters for filtering and pagination. ```shell curl "https://exist.io/api/2/insights/" -H "Authorization: Bearer [YOUR_TOKEN]" ``` -------------------------------- ### Get User Profile Stub - Python Source: https://developer.exist.io/deprecated/v1 Retrieves a basic profile stub for a specified user. This function demonstrates how to make a GET request to the API endpoint for user profiles using the 'requests' library in Python. It requires the user's ID or username and an authentication token. ```python import requests def get_user_profile_stub(user_id): url = f"https://exist.io/api/1/users/{user_id}/" headers = { "Authorization": "Token YOUR_API_TOKEN" } response = requests.get(url, headers=headers) if response.status_code == 200: return response.json() else: print(f"Error: {response.status_code}") return None # Example usage: # profile = get_user_profile_stub("josh") # if profile: # print(profile) ``` -------------------------------- ### User Authentication - OAuth2 Source: https://developer.exist.io/deprecated/v1 This section outlines the OAuth2 authentication flow, including authorization, token refreshing, and signing requests for API access. ```APIDOC ## OAuth2 Authentication ### Description Explains the OAuth2 authentication flow for authorizing requests to the Exist API. This is the primary method for authorizing access. ### Authorisation Flow Details the steps involved in the OAuth2 authorization process to grant your application access to user data. ### Refreshing an Access Token Instructions on how to refresh an expired OAuth2 access token to maintain continuous API access. ### Signing Requests Requests authenticated via OAuth2 should include the `Authorization: Bearer [tokenxyz]` header. ``` -------------------------------- ### GET /api/1/attributes/owned/ Source: https://developer.exist.io/deprecated/v1 Lists all attributes currently owned by the authenticated user and this service. ```APIDOC ## GET /api/1/attributes/owned/ ### Description Retrieves a list of all attributes owned by the authenticated user and managed by this service. ### Method GET ### Endpoint `/api/1/attributes/owned/` ### Parameters None ### Request Example ``` (No request body or query parameters for this endpoint) ``` ### Response #### Success Response (200 OK) Returns a JSON array of attribute objects owned by the authenticated user and this service. - **attribute** (string) - The name of the attribute. - **label** (string) - The human-readable label for the attribute. - **value** (any) - The current value of the attribute (can be null). - **service** (string) - The service that owns the attribute. - **priority** (integer) - The priority of the attribute. - **private** (boolean) - Indicates if the attribute is private. - **value_type** (integer) - The data type of the attribute's value. - **value_type_description** (string) - A description of the attribute's value type. #### Response Example ```json [ { "attribute": "steps", "label": "Steps", "value": null, "service": "fitbit", "priority": 1, "private": false, "value_type": 0, "value_type_description": "Integer" }, { "attribute": "steps_active_min", "label": "Active minutes", "value": null, "service": "fitbit", "priority": 2, "private": false, "value_type": 0, "value_type_description": "Integer" } ] ``` ``` -------------------------------- ### Correlations - Get All for Attribute Source: https://developer.exist.io/deprecated/v1 Retrieves all identified correlations associated with a given attribute. ```APIDOC ## Get All Correlations for Attribute ### Description Retrieves all identified correlations that exist between the specified attribute and other data points. ### Method GET ### Endpoint `/api/1/attributes/{slug}/correlations/` ### Parameters #### Path Parameters - **slug** (string) - Required - The slug of the attribute for which to retrieve correlations. ### Response #### Success Response (200) Returns a list of correlation objects detailing the relationships found for the specified attribute. ``` -------------------------------- ### Averages - Get All for Attribute Source: https://developer.exist.io/deprecated/v1 Retrieves all calculated averages related to a specific attribute. ```APIDOC ## Get All Averages for Attribute ### Description Retrieves all calculated average values associated with a specific attribute. ### Method GET ### Endpoint `/api/1/attributes/{slug}/averages/` ### Parameters #### Path Parameters - **slug** (string) - Required - The slug of the attribute for which to retrieve averages. ### Response #### Success Response (200) Returns a list of average values related to the specified attribute. ``` -------------------------------- ### Insights - Get All for Attribute Source: https://developer.exist.io/deprecated/v1 Retrieves all insights specifically related to a given attribute. ```APIDOC ## Get All Insights for Attribute ### Description Retrieves all insights associated with a particular attribute. ### Method GET ### Endpoint `/api/1/attributes/{slug}/insights/` ### Parameters #### Path Parameters - **slug** (string) - Required - The slug of the attribute for which to retrieve insights. ### Response #### Success Response (200) Returns a list of insight objects relevant to the specified attribute. ``` -------------------------------- ### Execute Script and Get Daily Tags (Python) Source: https://developer.exist.io/guide/read_client This snippet shows the execution flow of a Python script that retrieves the current date, fetches daily data from the Exist API, and prints formatted date information along with associated tags. It includes basic error handling for date retrieval and demonstrates how to iterate through attributes. ```Python # this is where our code starts executing when we run the script date = get_date() if date is None: print("Bad date input") else: # request the first page get_page(date, 1) # print a nicely formatted version of the date print(date.strftime("%A %d %B %Y").upper()) # now print our attributes as a comma-delimited list print(", ".join(attributes)) ``` -------------------------------- ### User Authentication - Simple Token Source: https://developer.exist.io/deprecated/v1 This section details how to obtain and use a simple token for authentication with the Exist API, suitable for personal read-only clients. ```APIDOC ## Simple Token Authentication ### Description Provides instructions for obtaining and using a simple token for authentication. This method is recommended for personal read-only clients. ### Requesting a Token To obtain a simple token, send a POST request with your username and password to the token endpoint. ### Method POST ### Endpoint `/api/1/auth/simple-token/` ### Parameters #### Request Body - **username** (string) - Required - Your Exist username. - **password** (string) - Required - Your Exist password. ### Request Example ```json { "username": "your_username", "password": "your_password" } ``` ### Response #### Success Response (200) - **token** (string) - The obtained simple token. #### Response Example ```json { "token": "your_simple_token_here" } ``` ### Signing Requests Requests made with simple token authentication must include the `Authorization: Token [tokenabc]` header. ``` -------------------------------- ### GET /api/1/users/:username/averages/ Source: https://developer.exist.io/deprecated/v1 Retrieves the most recent average values for each attribute for the authenticated user. ```APIDOC ## Get current averages ### Description Returns the most recent average values for each attribute. Only available for the currently authenticated user. ### Method GET ### Endpoint `/api/1/users/:username/averages/` ### Parameters No specific parameters are listed for this endpoint. ### Request Example ```bash curl -H "Authorization: Token [YOUR_TOKEN]" https://exist.io/api/1/users/$self/averages/ ``` ### Response #### Success Response (200) - **attribute** (string) - The name of the attribute. - **date** (string) - The date for which the averages are reported (YYYY-MM-DD). - **overall** (float) - The overall average value for the attribute on that date. - **monday** (float) - The average value for Monday. - **tuesday** (float) - The average value for Tuesday. - **wednesday** (float) - The average value for Wednesday. - **thursday** (float) - The average value for Thursday. - **friday** (float) - The average value for Friday. - **saturday** (float) - The average value for Saturday. - **sunday** (float) - The average value for Sunday. #### Response Example ```json [ { "attribute": "steps", "date": "2020-04-29", "overall": 4174.0, "monday": 4057.0, "tuesday": 6614.0, "wednesday": 4001.0, "thursday": 3923.0, "friday": 4528.0, "saturday": 3649.0, "sunday": 3904.0 }, { "attribute": "floors", "date": "2020-04-29", "overall": 13.0, "monday": 13.0, "tuesday": 16.0, "wednesday": 14.0, "thursday": 12.0, "friday": 14.0, "saturday": 13.0, "sunday": 12.0 } ] ``` ``` -------------------------------- ### GET /api/1/users/$self/insights/ Source: https://developer.exist.io/deprecated/v1 Retrieves a paged list of all insights for the currently authenticated user. ```APIDOC ## GET /api/1/users/:username/insights/ ### Description Returns a paged list of user’s insights. Only available for the currently authenticated user. ### Method GET ### Endpoint /api/1/users/:username/insights/ ### Parameters #### Query Parameters - **limit** (integer) - Optional - Number of values to return per page, starting with today. Optional, max is 100. - **page** (integer) - Optional - Page index. Optional, default is 1. - **date_min** (string) - Optional - Oldest date (inclusive) of results to be returned, in format `YYYY-mm-dd`. - **date_max** (string) - Optional - Most recent date (inclusive) of results to be returned, in format `YYYY-mm-dd`. ### Request Example ``` GET https://exist.io/api/1/users/$self/insights/?limit=10&page=1 ``` ### Response #### Success Response (200) - **count** (integer) - Total number of insights. - **next** (string) - URL for the next page of results. - **previous** (null) - URL for the previous page of results. - **results** (array) - An array of insight objects. - **created** (string) - The timestamp when the insight was created. - **target_date** (string) - The date the insight pertains to. - **html** (string) - The HTML representation of the insight. - **text** (string) - The plain text representation of the insight. - **type** (object) - Details about the type of insight. - **name** (string) - The name of the insight type. - **period** (integer) - The period for the insight type. - **priority** (integer) - The priority of the insight type. - **attribute** (object) - Details about the attribute associated with the insight. - **name** (string) - The name of the attribute. - **label** (string) - The human-readable label of the attribute. - **group** (object) - The group the attribute belongs to. - **name** (string) - The name of the attribute group. - **priority** (integer) - The priority of the attribute group. - **priority** (integer) - The priority of the attribute. #### Response Example ```json { "count": 740, "next": "https://exist.io/api/1/users/josh/insights/?page=2", "previous": null, "results": [ { "created": "2015-05-09T01:00:02Z", "target_date": "2015-05-08", "html": "
Friday night: Shortest sleep for 3 days
...", "text": "Friday night: Shortest sleep for 3 days\r\n", "type": { "name": "sleep_worst_since_x", "period": 1, "priority": 2, "attribute": { "name": "sleep", "label": "Time asleep", "group": { "name": "sleep", "priority": 3 }, "priority": 2 } } } ] } ``` ``` -------------------------------- ### Signing Requests Source: https://developer.exist.io/deprecated/v1 All API endpoints, except those in the OAuth2 flow, require authentication. Include your access token in the `Authorization` header. ```APIDOC ## Signing Requests ### Description To authenticate API requests, include your access token in the `Authorization` header using the `Bearer` schema. This applies to all endpoints except those directly involved in the OAuth2 authorization flow. ### Method All (GET, POST, PUT, DELETE, etc.) ### Endpoint All API endpoints ### Headers - **Authorization**: `Bearer [your_access_token]` ### Request Example **Example Request (Python):** ```python import requests access_token = 'YOUR_ACCESS_TOKEN' url = 'https://exist.io/api/some_endpoint' headers = {'Authorization': f'Bearer {access_token}'} response = requests.get(url, headers=headers) ``` ``` -------------------------------- ### Simple Token Authentication Source: https://developer.exist.io/reference/important_values Obtain a simple API token by sending your username and password. ```APIDOC ## POST /api/1/auth/simple-token/ ### Description Authenticates a user using their username and password to obtain a simple API token. ### Method POST ### Endpoint https://exist.io/api/1/auth/simple-token/ ### Parameters #### Query Parameters None #### Request Body - **username** (string) - Required - The user's username. - **password** (string) - Required - The user's password. ### Request Example ``` { "username": "your_username", "password": "your_password" } ``` ### Response #### Success Response (200) - **token** (string) - The obtained simple API token. #### Response Example ``` { "token": "tokenabc" } ``` ``` -------------------------------- ### Insights - Get All Source: https://developer.exist.io/deprecated/v1 Retrieves all available insights generated by the Exist platform for the authenticated user. ```APIDOC ## Get All Insights ### Description Retrieves all insights that have been generated for the authenticated user. ### Method GET ### Endpoint `/api/1/insights/` ### Response #### Success Response (200) Returns a list of insight objects, each representing a generated insight for the user. ``` -------------------------------- ### Initiate OAuth2 Authorization Request Source: https://developer.exist.io/reference/authentication/oauth2 This code snippet demonstrates how to construct the URL to initiate the OAuth2 authorization flow. It includes parameters like response type, client ID, redirect URI, and requested scopes. This URL is used to redirect the user to Exist's authorization page. ```shell # We can't really do this from the shell, but your URL would look like this: curl "https://exist.io/oauth2/authorize?response_type=code&client_id=[your_id]&redirect_uri=[your_uri]&scope=[your_scope]" ``` -------------------------------- ### Get Current Attribute Value and Label (Python) Source: https://developer.exist.io/guide/read_client This function retrieves the current label and value for a given attribute name from the Exist API. It makes a GET request to the 'attributes-with-values' endpoint, authenticates using a provided token, and parses the JSON response. It returns a dictionary containing the attribute's label and its most recent value, with basic error handling. ```Python import requests import datetime TOKEN = "[your_token]" def get_attribute(name): """ Gets the attribute's label and current value for today. """ result = {} # make an empty dictionary to store what we'll return # we're using the same attribute data call from the previous step url = 'https://exist.io/api/2/attributes/with-values/' response = requests.get(url, params={'attributes':name}, headers={'Authorization':f'Token {TOKEN}'}) if response.status_code == 200: try: data = response.json() attribute = data['results'][0] result['label'] = attribute['label'] result['value'] = attribute['values'][0]['value'] return result except: # we're expecting some fields to be there, but they may not be, # which would raise an exception # so let's just handle any failure very generally print("Couldn't get attribute") else: print("Error!", response.content) ``` -------------------------------- ### GET /api/1/users/:username/averages/attribute/:attribute/ Source: https://developer.exist.io/deprecated/v1 Retrieves a paged list of average values for a specific attribute. ```APIDOC ## Get all averages for attribute ### Description Returns a paged list of average values for an attribute. ### Method GET ### Endpoint `/api/1/users/:username/averages/attribute/:attribute/` ### Parameters #### Query Parameters - **limit** (integer) - Optional, max is 100. Number of values to return per page, starting with today. - **page** (integer) - Optional, default is 1. Page index. - **date_min** (string) - Optional. Oldest date (inclusive) of results to be returned, in format `YYYY-mm-dd`. - **date_max** (string) - Optional. Most recent date (inclusive) of results to be returned, in format `YYYY-mm-dd`. ### Request Example ```bash curl -H "Authorization: Token [YOUR_TOKEN]" https://exist.io/api/1/users/$self/averages/attribute/steps/ ``` ### Response #### Success Response (200) - **count** (integer) - The total number of results. - **next** (string/null) - URL for the next page of results, or null if there are no more pages. - **previous** (string/null) - URL for the previous page of results, or null if this is the first page. - **results** (array) - An array of average value objects for the specified attribute. - **attribute** (string) - The name of the attribute. - **date** (string) - The date for which the averages are reported (YYYY-MM-DD). - **overall** (float) - The overall average value for the attribute on that date. - **monday** (float) - The average value for Monday. - **tuesday** (float) - The average value for Tuesday. - **wednesday** (float) - The average value for Wednesday. - **thursday** (float) - The average value for Thursday. - **friday** (float) - The average value for Friday. - **saturday** (float) - The average value for Saturday. - **sunday** (float) - The average value for Sunday. #### Response Example ```json { "count": 11, "next": null, "previous": null, "results": [ { "attribute": "steps", "date": "2020-04-29", "overall": 4174.0, "monday": 4057.0, "tuesday": 6614.0, "wednesday": 4001.0, "thursday": 3923.0, "friday": 4528.0, "saturday": 3649.0, "sunday": 3904.0 }, { "attribute": "steps", "date": "2020-03-30", "overall": 4062.0, "monday": 4057.0, "tuesday": 6618.0, "wednesday": 3610.0, "thursday": 3923.0, "friday": 4063.0, "saturday": 3636.0, "sunday": 3904.0 } ] } ``` ``` -------------------------------- ### Get User Today Overview (cURL & Python) Source: https://developer.exist.io/deprecated/v1 Retrieves an overview of the user's personal details and their current grouped attributes. Requires an Authorization header with a Bearer token. Returns a JSON object. ```curl curl -H "Authorization: Token [YOUR_TOKEN]" https://exist.io/api/1/users/$self/today/ ``` ```python import requests requests.get("https://exist.io/api/1/users/$self/today/", headers={'Authorization':'Token [YOUR_TOKEN]'}) ``` -------------------------------- ### GET /api/1/users/$self/insights/attribute/:attribute/ Source: https://developer.exist.io/deprecated/v1 Retrieves a paged list of user insights for a specific attribute. ```APIDOC ## GET /api/1/users/:username/insights/attribute/:attribute/ ### Description Returns a paged list of user’s insights for a specific attribute. Only available for the currently authenticated user. ### Method GET ### Endpoint /api/1/users/:username/insights/attribute/:attribute/ ### Parameters #### Path Parameters - **attribute** (string) - Required - The attribute for which to retrieve insights (e.g., `sleep`). #### Query Parameters - **limit** (integer) - Optional - Number of values to return per page, starting with today. Optional, max is 100. - **page** (integer) - Optional - Page index. Optional, default is 1. - **date_min** (string) - Optional - Oldest date (inclusive) of results to be returned, in format `YYYY-mm-dd`. - **date_max** (string) - Optional - Most recent date (inclusive) of results to be returned, in format `YYYY-mm-dd`. ### Request Example ``` GET https://exist.io/api/1/users/$self/insights/attribute/sleep/?limit=10&page=1 ``` ### Response #### Success Response (200) - **count** (integer) - Total number of insights for the attribute. - **next** (string) - URL for the next page of results. - **previous** (null) - URL for the previous page of results. - **results** (array) - An array of insight objects for the specified attribute. - **created** (string) - The timestamp when the insight was created. - **target_date** (string) - The date the insight pertains to. - **html** (string) - The HTML representation of the insight. - **text** (string) - The plain text representation of the insight. - **type** (object) - Details about the type of insight. - **name** (string) - The name of the insight type. - **period** (integer) - The period for the insight type. - **priority** (integer) - The priority of the insight type. - **attribute** (object) - Details about the attribute associated with the insight. - **name** (string) - The name of the attribute. - **label** (string) - The human-readable label of the attribute. - **group** (object) - The group the attribute belongs to. - **name** (string) - The name of the attribute group. - **priority** (integer) - The priority of the attribute group. - **priority** (integer) - The priority of the attribute. #### Response Example ```json { "count": 220, "next": "https://exist.io/api/1/users/josh/insights/attribute/sleep/?page=2", "previous": null, "results": [ { "created": "2015-05-09T01:00:02Z", "target_date": "2015-05-08", "html": "
Friday night: Shortest sleep for 3 days
...", "text": "Friday night: Shortest sleep for 3 days...", "type": { "name": "sleep_worst_since_x", "period": 1, "priority": 2, "attribute": { "name": "sleep", "label": "Time asleep", "group": { "name": "sleep", "priority": 3 }, "priority": 2 } } } ] } ``` ``` -------------------------------- ### Example Custom Tag Data Structure (JSON) Source: https://developer.exist.io/deprecated/v1 This JSON object illustrates the structure of custom tag data returned by the today endpoint. It includes group information, priority, and a list of items, each with attributes like label, value, and service. ```json { "group": "custom", "label": "Custom tracking", "priority": 3, "items": [ { "attribute": "custom", "label": "Custom tracking", "value": "accounting,", "service": "exist_for_android", "priority": 1, "private": true, "value_type": 2, "value_type_description": "String" }, { "attribute": "accounting", "label": "Accounting", "value": 1, "service": "builtin", "priority": 2, "private": true, "value_type": 0, "value_type_description": "Integer" }, { "attribute": "tired", "label": "Tired", "value": 0, "service": "builtin", "priority": 2, "private": true, "value_type": 0, "value_type_description": "Integer" } ] } ``` -------------------------------- ### Get a Specific Attribute Source: https://developer.exist.io/deprecated/v1 Retrieves a paged list of all values for a specific attribute of the authenticated user. ```APIDOC ## GET /api/1/users/:username/attributes/:attribute/ ### Description Returns a paged list of all values from a specific attribute, omitting the attribute object itself. ### Method GET ### Endpoint `/api/1/users/:username/attributes/:attribute/` ### Parameters #### Query Parameters - **limit** (number) - Optional - Number of values to return per page. Max is 100. - **page** (number) - Optional - Page index. Default is 1. - **date_max** (string) - Optional - Most recent date (inclusive) of results to be returned, in format `YYYY-mm-dd`. ### Request Example ```bash curl -H "Authorization: Token [YOUR_TOKEN]" https://exist.io/api/1/users/$self/attributes/steps/ ``` ### Response #### Success Response (200) - **count** (number) - The total number of values available. - **next** (string) - URL for the next page of results, or null if none. - **previous** (string) - URL for the previous page of results, or null if none. - **results** (array) - A list of attribute values. - **value** (any) - The value of the attribute. - **date** (string) - The date the value was recorded (YYYY-mm-dd). #### Response Example ```json { "count": 655, "next": "https://exist.io/api/1/users/josh/attributes/steps/?page=2", "previous": null, "results": [ { "value": 3783, "date": "2015-05-08" }, { "value": 6177, "date": "2015-05-07" } ] } ``` ``` -------------------------------- ### Correlations - Get Strongest for All Attributes Source: https://developer.exist.io/deprecated/v1 Retrieves the strongest correlations identified across all attributes for the authenticated user. ```APIDOC ## Get the Strongest Correlations for All Attributes ### Description Retrieves a summary of the strongest correlations found across all of the user's attributes. ### Method GET ### Endpoint `/api/1/correlations/` ### Response #### Success Response (200) Returns a JSON object containing the strongest correlations identified across all attributes. ```