HAppi API

Base URL: /v1, Version: 1.0.0

Track symptoms with the HAppi API

Default request content-types: application/json
Default response content-types: application/json
Schemes: https

Summary

Tag: Symptom

Operation Description
GET /symptoms

Retrieve symptoms

GET /symptoms/occurrences

Get a list of symptoms with the linked occurrences for the current user.

POST /occurrences

Add a symptom occurrence

GET /stats/count

Count how many occurrences of some symptoms occurred between a start date and an end date, based on a given unit, for a given set of symptoms.

Tag: Occurrence

Operation Description
GET /symptoms/occurrences

Get a list of symptoms with the linked occurrences for the current user.

GET /occurrences

Get the list of symptom occurences

POST /occurrences

Add a symptom occurrence

DELETE /occurrences

Remove the occurrence associated to the id

GET /stats/count

Count how many occurrences of some symptoms occurred between a start date and an end date, based on a given unit, for a given set of symptoms.

POST /reports

Create a new shared occurrences report.

Tag: Authentication

Operation Description
POST /auth

Create account

POST /auth/sign_in

Login

DELETE /auth/sign_out

Log out

GET /auth/validate_token

Check if the given token is still valid.

Tag: Statistic

Operation Description
GET /stats/count

Count how many occurrences of some symptoms occurred between a start date and an end date, based on a given unit, for a given set of symptoms.

Tag: SymptomsUser

Operation Description
GET /symptoms_user

Return a list of symptoms associated to the logged in user

POST /symptoms_user

Add the given symptoms_user to the database

DELETE /symptoms_user

Remove the symptom_id associated to the user

Tag: SharedOccurrences

Operation Description
POST /reports

Create a new shared occurrences report.

GET /reports

Retrieve a report based on a token and an email address.

Tag: Report

Operation Description
POST /reports

Create a new shared occurrences report.

GET /reports

Retrieve a report based on a token and an email address.

Paths

Create account

POST /auth

Tags: Authentication

Create a new account for the given email with the given password.

application/json

The new account information

Uses default content-types: application/json

200 OK

Account created. The headers that are returned must be included in every following request in order to valid the authentication.

Access-Token

This serves as the user's password for each request. A hashed version of this value is stored in the database for later comparison.

string
Client

This enables the use of multiple simultaneous sessions on different clients. (For example, a user may want to be authenticated on both their phone and their laptop at the same time.)

string
Uid

A unique value that is used to identify the user. This is necessary because searching the DB for users by their access token will make the API susceptible to timing attacks.

string
Token-Type

Always 'Bearer'

string , x ∈ { Bearer }
Expiry

The date at which the current session will expire. This can be used by clients to invalidate expired tokens without the need for an API request.

string
422 Unprocessable Entity

An error occurred and the error is detailled in the errors key of the response

Login

POST /auth/sign_in

Tags: Authentication

Login an account by checking the {email, password} pair. The headers that are returned must be included in every following request in order to valid the authentication.

application/json

The new account information

Uses default content-types: application/json

200 OK

Account created.

Access-Token

This serves as the user's password for each request. A hashed version of this value is stored in the database for later comparison.

string
Client

This enables the use of multiple simultaneous sessions on different clients. (For example, a user may want to be authenticated on both their phone and their laptop at the same time.)

string
Uid

A unique value that is used to identify the user. This is necessary because searching the DB for users by their access token will make the API susceptible to timing attacks.

string
Token-Type

Always 'Bearer'

string , x ∈ { Bearer }
Expiry

The date at which the current session will expire. This can be used by clients to invalidate expired tokens without the need for an API request.

string
401 Unauthorized

Invalid login credentials.

422 Unprocessable Entity

An error occurred and the error is detailled in the errors key of the response

Log out

DELETE /auth/sign_out

Tags: Authentication

Log out the current account. The request must contains the authentication headers (uid, client, access-token).

uid

Authentication information.

header string
client

Authentication information.

header string
access-token

Authentication information.

header string

Uses default content-types: application/json

200 OK

Successfully logged out.

404 Not Found

The user was not logged in.

Check if the given token is still valid.

GET /auth/validate_token

Tags: Authentication

Returns true if the given token is valid or false.

uid

Authentication information.

header string
client

Authentication information.

header string
access-token

Authentication information.

header string

Uses default content-types: application/json

200 OK

Token is valid.

401 Unauthorized

Token is not valid.

Remove the occurrence associated to the id

DELETE /occurrences

Tags: Occurrence
occurrence_id

Id of the occurrence to delete

query integer

Uses default content-types: application/json

200 OK

The occurrence linked to the id is correctly deleted

401 Unauthorized

The user has not the authorization

422 Unprocessable Entity

The given occurrence_id is not valid or does not exist for the useret

Get the list of symptom occurences

GET /occurrences

Tags: Occurrence

Get the list of symptom occurences from the database

Uses default content-types: application/json

200 OK

List of symptom occurences

401 Unauthorized

Not allowed to get list of symptom occurences

Add a symptom occurrence

POST /occurrences

Tags: Occurrence, Symptom

Add the received symptom occurrence to the database.

application/json

The occurrence to add.

uid

Authentication information.

header string
client

Authentication information.

header string
access-token

Authentication information.

header string

Uses default content-types: application/json

201 Created

Occurrence correctly added.

422 Unprocessable Entity

The given object is not a valid occurrence.

Retrieve a report based on a token and an email address.

GET /reports

Tags: Report, SharedOccurrences

Return the report associated to the given token. The report was sent to the given email address. It contains all the symptoms and occurrences that the patient agreed to share with its doctor.

token

A token identifying the report to access.

query string
email

The email address to which the report was sent.

query string

Uses default content-types: application/json

200 OK

The report was found, the token and email were valid. The expiration_date is not passed yet.

Create a new shared occurrences report.

POST /reports

Tags: Occurrence, SharedOccurrences, Report

Create a new shared occurrences report containing all the occurrences of the user between the given start_date and end_date. It is associated to the email address of a doctor and have an expiration date. The value of expiration_date is optionnal and will be set to 2 weeks from now by default.

Uses default content-types: application/json

The report parameters

Uses default content-types: application/json

201 Created

The shared occurrences report has been created

Count how many occurrences of some symptoms occurred between a start date and an end date, based on a given unit, for a given set of symptoms.

GET /stats/count

Tags: Statistic, Symptom, Occurrence

Compute the number of occurrences that occurred for all the symptoms of the current user. The default unit to count the occurrences is per 'days' but it can also be counted per 'hours', 'months' and 'years'. The list of symptoms can be filtered via the 'symptoms' parameter that receives a list of 'symptom_id'. The occurrences can be filtered by using the 'start' and 'end' date parameters.

start

Start date of the occurrences to count. Any occurrences that were created before this date will be ignored.

query string (date-time)
end

End date of the occurrences to count. Any occurrences that were created after this date will be ignored.

query string (date-time)
unit

The 'unit' parameter must take one of the following value: 'hours', 'days', 'months', 'years'. The default value is per 'days'. This parameter determine how to count occurrences.

query string , x ∈ { hours , days (default) , months , years }
symptoms

An array of symptoms' id to include in the result. Only those symptoms will be included in the result. If this parameter is not present, all the symptoms will be included.

query integer[]

Uses default content-types: application/json

200 OK

An array of SymptomsCounts

422 Unprocessable Entity

Invalid parameter, the end date is before the start date.

Retrieve symptoms

GET /symptoms

Tags: Symptom

The Symptom endpoint returns information about the symptom . The response includes the symptoms filtered by name and category

name

Name of researched symptoms.

query string
category

Category of researched symptoms.

query string
uid

Authentication information.

header string
client

Authentication information.

header string
access-token

Authentication information.

header string

Uses default content-types: application/json

200 OK

An array of symptoms with their associated factors.

Get a list of symptoms with the linked occurrences for the current user.

GET /symptoms/occurrences

Tags: Symptom, Occurrence

The returned list contained all the symptoms along with their occurrences that occurred.

Uses default content-types: application/json

200 OK

An array of symptoms, associated with their occurrences.

Remove the symptom_id associated to the user

DELETE /symptoms_user

Tags: SymptomsUser
symptom_id

The symptom's id to link to the user (that is currently logged in)

query integer

Uses default content-types: application/json

200 OK

The symptoms_user is correctly deleted

401 Unauthorized

The user has not the authorization

422 Unprocessable Entity

The given symptom_id is not valid or does not exist for the user

Return a list of symptoms associated to the logged in user

GET /symptoms_user

Tags: SymptomsUser

Uses default content-types: application/json

200 OK

A list of symptoms used by the logged in user.

401 Unauthorized

The user has not the authorization

Add the given symptoms_user to the database

POST /symptoms_user

Tags: SymptomsUser

Uses default content-types: application/json

The symptom's id to link to the user (that is currently logged in)

Uses default content-types: application/json

200 OK

The symptoms_user is correctly added

401 Unauthorized

The user has not the authorization

422 Unprocessable Entity

The given symptom_id is not valid or already exist for the user

Schema definitions

Account: object

An account from https://github.com/lynndylanhurley/devise_token_auth

id: number
provider: string
uid: string
name: string
nickname: string
image: string
email: string

Category: object

Categorize the symptoms to help finding them.

id: number

Unique ID of the category.

name: string

Name of the category.

short_description: string

A short description of the category.

long_description: string

A long description of the category.

parent_id: number

ID of the parent category.

children: object[]

CountPerDate: object

A date associated to a number of occurrences that occurred at that date. Note that we don't know what is the unit represented by date. The occurrences can be grouped by hour, day, month, year, ...

date: string (date-time)
count: integer

Factor: object

A factor describe more accuratly an occurrence of a symptom. For example it can describe the intensity of pain or the precise location of a pain.

id: number

Unique ID of the factor

name: string

Name of the factor.

type: string

Type of the factor.

FactorInstance: object

Factor with a value.

id: number

Unique ID of the instance.

factor_id: number

Unique ID of the linked factor.

value: string

Value of the factor. Depending on the type of the factor, the value can be a number, a date, etc. This field always store the textual representation.

GPSCoordinates: object

A GPS location as described in https://github.com/apache/cordova-plugin-geolocation#coordinates

latitude: number (float)

Latitude in degrees.

longitude: number (float)

Longitude in degrees.

altitude: number (float)

Altitude in meters above the ellipsoid.

accuracy: number (float)

Accuracy of position in meters.

altitude_accuracy: number (float)

Accuracy of altitude in meters.

heading: number (float)

Direction if travel, specified in degress couting clockwise relative to the true north.

speed: number (float)

Current ground speed of the device, specified in meters per second.

NewAccount: object

A new account containing an email, a password and a confirmation of the password.

email: string

The email address of the new account

password: string (password)

The password of the new account

password_confirmation: string (password)

A confirmation of the password of the new account

Occurrence: object

An occurrence of a symptom describe the moment when the symptom appeared and add some factors to describe the occurrence.

id: number

Unique ID of the occurrence.

symptom_id: number

Unique ID of the linked symptom.

date: string (date-time)

Date and time when the symptom occured.

gps_coordinate: GPSCoordinates
factors: object[]

Report: object

A report used to share occurrences with a doctor

id: string
start_date: string (date-time)
end_date: string (date-time)
email: string
expiration_date: string (date-time)
token: string
user_id: string
symptoms: object[]

ReportParameters: object

The parameters to POST a report.

start_date: string (date-time)
end_date: string (date-time)
email: string
expiration_date: string (date-time)

This value is optionnal and will be set to 2 weeks from now by default.

Symptom: object

A symptom.

id: number

Unique ID of the symptom.

name: string

Name of the symptom.

short_description: string

A short description of the symptom.

long_description: string

A long description of the symptom.

category: object[]
gender_filter: string

The gender to which the symptom applies. Possible values are 'male' for male, 'female' for female and 'both' for both.

SymptomCount: object

A symptom represented only by its name and id, containing an array of dates associated with a number of occurrences that occurred at that particular date.

id: number

Unique ID of the symptom.

name: string

Name of the symptom.

counts: object[]

SymptomsCounts: object

An array of symptoms represented only by their names and id's, each containing an array of dates associated with a number of occurrences that occurred at that particular date. The unit indicates the period between two successives dates.

unit: string , x ∈ { hour , day (default) , month , year }
symptoms: object[]

SymptomsUser: object

Associated a user to a symptom

user_id: string
symptom_id: integer

SymptomWithFactors:

A symptom associated to a list of factors that can be used to describe an occurrence of this symptom more precisly.

factors: object[]

SymptomWithOccurrences:

A symptom with a list of all the occurrences that occurred for the current user.

occurrences: object[]