Memair Docs logoMemair Docs

Welcome

Welcome to the Memair API documentation.

This API document is designed for those interested in developing on our platform. Memair is continuously under development and this API will evolve.

Memair stores user’s data in structured models. Memair data models are designed to extract maximum insight for users.

Deprecation Policy

Memair adheres to a deprecation schedule however, any endpoint or data structure may be changed or deprecated if there is a security issue. Currently all endpoints are Beta (except for those with deprecation notices).

Alpha endpoints

Alpha endpoints are in active development and will likely change or become deprecated.

Beta endpoints

Beta endpoints are being tested more widely with beta users and are unlikely to change. Any non backward compatible changes or deprecation will have at least 4 weeks notice.

Gamma endpoints

Gamma endpoints have been throughly tested. Any non backward compatible changes or deprecation will have at least 6 months notice.

Notices

No deprecation notices at this moment

Bug Beer Bounty 🐞🍺⚓️

Find a Bug and I’ll buy you a beer 🍻 and give you an honourable mention here.

Bugs

  • GraphiQL sometimes hangs on “Loading…”, temporary fix is to hit refresh

API Rate Limits

There are no hard set API limits while this project is in Alpha. Out of courtesy please limit api requests to;

  • one request per second for regular endpoints
  • batch sizes below 2000 with one request per minutes for bulk endpoints

We would appreciate feedback on system performance.

Quick Access

If you would like to have a quick play with the api, click here to generate an access token for the currently logged in user. This access token is temporary (10 days). Create an app for longer lasting access tokens.

Create an App

Log into the Memair App

Developer Tools > API Keys > New Application

Select the appropriate scopes required for the app.

Request Authorization

Send user to;

https://memair.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://redirect.com&response_type=code&scope=location_read+location_write

And collect USER_CODE in the call back url

Request Access Token

To request the access token, you should use the returned code from above and exchange it for an access token.

curl \
  -F grant_type=authorization_code \
  -F client_id=YOUR_CLIENT_ID \
  -F client_secret=YOUR_CLIENT_SECRET \
  -F code=USERS_CODE \
  -F redirect_uri=http://redirect.com \
  -X POST https://memair.com/oauth/token
{
  "access_token": "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",
  "token_type": "bearer",
  "created_at": 1457567765
}
{
  "error": true,
  "message": "Invalid score"
}

About GraphQL

GraphQL is a powerful API query language

GraphQL is a data query language which provides an alternative to REST and ad-hoc web service architectures. It allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server. It is a strongly typed runtime which allows clients to dictate what data is needed, therefore preventing excessively large amounts of data being returned.

GraphiQL

An interactive console for GraphQL

GraphiQL is an interactive console for GraphQL queries. GraphiQL queries are scoped to the currently logged in user.

GraphiQL Console

GraphiQL includes a Documentation Explorer which shows the various Query and Mutation options

GraphiQL Documentation

Example Query

Example auth and queries for Memair

GraphQL provides a complete and understandable description of the data in Memair.

Parameters
query
GraphQL query. See above for more details
access_token
access token with correct scopes for memories being accessed. See Request Access Token for more details
curl \
  -F query='{Biometrics(first: 1 order: timestamp_desc type: weight) {timestamp value biometric_type {name unit}}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com/graphql
data = {
  'query' : '{Biometrics(first: 1 order: timestamp_desc type: weight) {timestamp value biometric_type {name unit}}}',
  'access_token': 'YOUR_ACCESS_TOKEN'
}
import requests
r = requests.post("https://memair.com/graphql", data)
print(r.text)
{
  "data": {
    "Biometrics": [
      {
        "value": 37.8,
        "timestamp": "2018-01-01T00:00:00Z",
        "type": "Internal Body Temperature"
      },
      {
        "value": 80,
        "timestamp": "2018-01-01T00:00:00Z",
        "type": "Weight"
      }
    ]
  }
}
{
  "errors": [
    {
      "message": "Field 'foobar' doesn't exist on type 'Biometric'",
      "locations": [{"line":1,"column":32}]
    }
  ],
  "data": {}
}

About Memair's Models

Memair’s goal is to empower humans by modelling the data of human activity. These models are structured to maximise insight for individuals. Most models are strongly prescribed so that they are useful across applications.

Biometrics

This model is used to store user data for defined biometric types like blood pressure, weight, body temperature.

Model

Grain: 1 row per biometric type per timestamp. Duplicates will be deleted leaving the latest version.

Name Type Notes
id integer assigned by memair
biometric_type biometric type required
value integer required
timestamp timestamp assigned by memair if null
source string nullable
notes string nullable
updated_at timestamp assigned by memair

Example interactions

See the Documentation Explorer for full list of mutations and query filters.

{
  Biometrics(first: 1, order: timestamp_desc, type: weight) {
    timestamp
    value
    biometric_type {
      name
      unit
    }
  }
}
mutation {
  CreateBiometric(value: 80, type: weight) {
    timestamp
    value
    biometric_type {
      name
      unit
    }
  }
}

curl \
  -F query='{Biometrics(first: 1 order: timestamp_desc type: weight) {timestamp value biometric_type {name unit}}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com//graphql
{
  "data": {
    "Biometrics": [
      {
        "timestamp": "2018-01-01T00:00:00Z",
        "value": 80,
        "biometric_type": {
          "name": "Body Weight",
          "unit": "Kilogram"
        }
      }
    ]
  }
}

Biometric Types

The records in this model are prescribed by Memair. Request new biometric types here.

Model

Grain: 1 row per biometric type

Name Type Notes
name string  
slug string used when creating & querying biometrics
unit string  
unit_symbol string  
about string nullable
{
  BiometricTypes {
    slug
  }
}
curl \
  -F query='{BiometricTypes{slug}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com//graphql
data = {
  'query' : '{BiometricTypes{slug}}',
  'access_token': 'YOUR_ACCESS_TOKEN'
}
import requests
r = requests.post("https://memair.com/graphql", data)
print(r.text)
{
  "data": {
    "BiometricTypes": [
      {
        "slug": "diastolic_pressure"
      },
      {
        "slug": "internal_body_temp"
      },
      {
        "slug": "systolic_pressure"
      },
      {
        "slug": "weight"
      }
    ]
  }
}

Locations

Models user geospatially

Parameters
lat
Latitude
lon
Longitude
timestamp
Timestamp of location
altitude
Altitude (meters)
point_accuracy
Point Accuracy (meters)
altitude_accuracy
Altitude Accuracy (meters)
heading
Heading (degrees from north)
speed
Speed (meters per second)
source
Source of location

Grain: 1 row per location type per timestamp. Duplicates will be deleted leaving the latest version.

Example interactions

See the Documentation Explorer for full list of mutations and query filters.

{
  Locations(first: 50, order: timestamp_desc) {
    lat
    lon
    timestamp
  }
}

mutation {
  CreateLocation(lat: 42, lon: 42) {
    lat
    lon
    timestamp
  }
}
curl \
  -F query='{Locations(first: 50, order: timestamp_desc) {lat, lon, timestamp}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com//graphql
{
  "data": {
    "Locations": [
      {
        "lat": 42,
        "lon": 42,
        "timestamp": "2018-05-26T11:52:23Z"
      },
      ...
      {
        "lat": 42,
        "lon": 42,
        "timestamp": "2018-05-26T11:52:21Z"
      }
    ]
  }
}

Physical Activities

Models defined physical activities

This model is used to store user data for defined physical activity types like blood pressure, weight, body temperature.

Model

Grain: 1 row per physical activity type per timestamp. Duplicates will be deleted leaving the latest version.

Name Type Notes
id integer assigned by memair
physical_activity_type physical activity type required
duration integer in seconds & nullable
timestamp timestamp assigned by memair if null
ended_at timestamp assigned by memair based on duration
source string nullable
notes string nullable
updated_at timestamp assigned by memair

Example interactions

See the Documentation Explorer for full list of mutations and query filters.

{
  PhysicalActivities(first: 50, order: timestamp_desc, type: all) {
    timestamp
    physical_activity_type {
      name
    }
  }
}
mutation {
  CreatePhysicalActivity(type: acroyoga) {
    timestamp
    physical_activity_type {
      name
    }
  }
}
curl \
  -F query='{PhysicalActivities(first: 50, order: timestamp_desc, type: all) {timestamp, physical_activity_type {name}}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com//graphql
{
  "data": {
    "PhysicalActivities": [
      {
        "timestamp": "2018-05-19T03:55:10Z",
        "physical_activity_type": {
          "name": "Skating"
        }
      }
      ...
      {
        "timestamp": "2018-05-123T03:24:55Z",
        "physical_activity_type": {
          "name": "Polo"
        }
      }
    ]
  }
}

Physical Activity Types

The records in this model are prescribed by Memair. Request new physical activity types here.

Model

Grain: 1 row per physical activity type

Name Type Notes
name string  
slug string used when creating & querying physical activities
about string nullable
{
  PhysicalActivityTypes {
    slug
  }
}
curl \
  -F query='{PhysicalActivityTypes{slug}}' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com//graphql
data = {
  'query' : '{PhysicalActivityTypes{slug}}',
  'access_token': 'YOUR_ACCESS_TOKEN'
}
import requests
r = requests.post("https://memair.com/graphql", data)
print(r.text)
{
  "data": {
    "PhysicalActivityTypes": [
      {
        "slug": "acroyoga"
      },
      ...
      {
        "slug": "zumba"
      }
    ]
  }
}

Proposed Models

A list of proposed models

Please contact us if you have suggestions for new models or would like us to focus on currently proposed models.

  • Bio functions
    • Passed gas
    • Menstruated
  • Digital activities
    • Visited website
    • Took photo
  • Ingestion
    • An apple
    • Meclizine 25mg
    • Ibuprofen 400mg
  • Injection
    • Flu shot (LAIV)
    • Morphine 20mg
  • Memory
    • Belief
    • Dreams
    • Goal
    • Idea
    • Memoir
    • Observation?
    • Prediction?
    • Thought
    • Value
  • Physical sensations
    • Throbbing in right foot
    • Sharp pain in front left brain

/locations

Create Location

Parameters
latitude
Latitude
longitude
Longitude
timestamp
Timestamp of location
altitude
Altitude (meters)
point_accuracy
Point Accuracy (meters)
altitude_accuracy
Altitude Accuracy (meters)
Heading
heading (degrees from north)
Speed
speed (meters per second)
source
Source of location
access_token
access token with correct scopes for memories being accessed. See Request Access Token for more details

Adds a location to users memair.

curl \
  -F latitude=42 \
  -F longitude=42 \
  -F 'timestamp=2018-01-01 00:00:00' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com/api/v1/locations
data = {
  'latitude' : 42,
  'longitude': 42,
  'timestamp': '2018-01-01 00:00:00',
  'access_token': 'YOUR_ACCESS_TOKEN'
}
import requests
r = requests.post("https://memair.com/api/v1/locations", data)
print(r.text)
{
  "altitude": null,
  "altitude_accuracy": null,
  "application": "Greg's Test App",
  "created_at": "2018-01-07T12:14:34.416Z",
  "email": "otto@gmeow.com",
  "heading": null,
  "id": 2134,
  "latitude": 42.0,
  "longitude": 42.0,
  "point_accuracy": null,
  "source": null,
  "speed": null,
  "timestamp": "2018-01-01T00:00:00.000Z",
  "tzid": "UTC",
  "updated_at": "2018-01-07T12:14:34.416Z"
}
{
  "errors": {
    "longitude": [
      "is not a number"
    ]
  },
  "status": "not saved"
}

/bulk/locations

Create Bulk Locations

Parameters
json
JSON blob containing list of locations using parameters as above
access_token
access token with correct scopes for memories being accessed. See Request Access Token for more details

Adds multiple locations to users memair.

curl \
  -F 'json=[{"latitude": 42, "longitude": 42, "timestamp": "2018-01-01 00:00:00"}, {"latitude": 42, "longitude": 42, "timestamp": "2018-01-01 00:05:00", "point_accuracy": 100}]' \
  -F access_token=YOUR_ACCESS_TOKEN \
  -X POST https://memair.com/api/v1/bulk/locations
data = {
  'json' : '[{"latitude": 42, "longitude": 42, "timestamp": "2018-01-01 00:00:00"}, {"latitude": 42, "longitude": 42, "timestamp": "2018-01-01 00:05:00", "point_accuracy": 100}]',
  'access_token': 'YOUR_ACCESS_TOKEN'
}
import requests
r = requests.post("https://memair.com/api/v1/bulk/locations", data)
print(r.text)
{
  "altitude": null,
  "altitude_accuracy": null,
  "application": "Greg's Test App",
  "created_at": "2018-01-07T12:14:34.416Z",
  "email": "otto@gmeow.com",
  "heading": null,
  "id": 2134,
  "latitude": 42.0,
  "longitude": 42.0,
  "point_accuracy": null,
  "source": null,
  "speed": null,
  "timestamp": "2018-01-01T00:00:00.000Z",
  "tzid": "UTC",
  "updated_at": "2018-01-07T12:14:34.416Z"
}
{
  "docs": "http://memair.com/docs",
  "error": "Not authorized",
  "info": "Token was unauthorized"
}