Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add new articles using the new wallabag API and Python
#!/usr/bin/env python3
import requests
# only these 5 variables have to be set
HOST = 'https://wallabag.example.org'
USERNAME = 'username'
PASSWORD = 'password'
CLIENTID = 'cryptic_client_id'
SECRET = 'secret'
gettoken = {'username': USERNAME, 'password': PASSWORD, 'client_id': CLIENTID, 'client_secret': SECRET, 'grant_type': 'password'}
r = requests.get('{}/oauth/v2/token'.format(HOST), gettoken)
access = r.json().get('access_token')
# can be replaced by a loop over many URLs
url = 'https://example.com' # URL of the article
a = 0 # should the article be already read? 0 or 1
f = 0 # should the article be added as favorited? 0 or 1
article = {'url': url, 'archive': a , 'starred': f, 'access_token': access}
r = requests.post('{}/api/entries.json'.format(HOST), article)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.