In [1]:
from memair import Memair
import collections
# Use Otto the sandbox user's access token or create your own at https://memair.com/temporary_access_token
access_token = '0000000000000000000000000000000000000000000000000000000000000000'

user = Memair(access_token)
In [2]:
first_page_query = '''
  {
    Locations(
      first: 5
      order_by: timestamp
      order: asc
    ) {
      id
      lat
      lon
    }
  }

'''

first_page = user.query(first_page_query)['data']['Locations']

# Extract last id of page for use in next page
last_id_of_first_page = first_page[-1]['id']
In [3]:
second_page_query = '''
  {
    Locations(
      first: 5
      order_by: timestamp
      order: asc
      after: %s
    ) {
      id
      lat
      lon
    }
  }

''' % last_id_of_first_page # setting last id of previous page as the after argument

second_page = user.query(second_page_query)['data']['Locations']
In [4]:
# Total locations returned
locations = first_page + second_page
len(locations)
Out[4]:
10
In [5]:
# Ensure collected locations are unique
collections.Counter(location['id'] for location in locations)
Out[5]:
Counter({'42884351': 1,
         '42986348': 1,
         '42884366': 1,
         '42986347': 1,
         '42986346': 1,
         '42986345': 1,
         '42986344': 1,
         '42986343': 1,
         '42986342': 1,
         '42986341': 1})