import requests # setup request headers host = 'http://192.168.1.100:800' form = 'json' path = '/api/entries.{ext}'.format(ext=form) pathToken = '/oauth/v2/token' # auth stuff user = 'wallabag' secret = open("/home/anish/usr/dev/secrets/wallabag", "r") password = secret.readline()[:-1] clientID = secret.readline()[:-1] clientSecret = secret.readline()[:-1] paramsToken = dict({'client_id': clientID, 'client_secret': clientSecret, 'username': user, 'grant_type': 'password', 'password': password}) # params for the get request sort = 'updated', archive = 1 perPage = 15 since = 0 detail = 'metadata' # get the token token = requests.post(host+pathToken, data=paramsToken) token = token.json()['access_token'] # create the params for the request params = dict({'access_token': token, 'sort': sort, 'archive': archive, 'perPage': perPage, #'detail': detail, 'since': since}) # make request and handle response # wallabag gives us the entire article, instead of just metadata :/ r = requests.get(host+path, params=params) for links in r.json()['_embedded']['items']: count = 0 for (key, link) in links.items(): if key == 'title' or key == 'url': print(link) count = count + 1 if count == 2: print() count = 0