![]() |
||
---|---|---|
wallabagapi | ||
.gitignore | ||
.gitlab-ci.yml | ||
CHANGELOG | ||
CONTRIBUTING.md | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
VERSION.txt | ||
requirements-dev.txt | ||
requirements.txt | ||
setup.cfg | ||
setup.py | ||
wallabag.png | ||
wallabag_api_key.png |
README.rst
Wallabag API
Python API for Wallabag v2.4.2
Requirements :
- httpx
Installation:
to get the project, from your virtualenv, do :
//git/afpy.org/foxmask/wallabagapi/ git clone https:
or
pip install wallabagapi
Creating a post :
- request the token, if you don't have it yet
- create the post
#!/usr/bin/env python
import httpx
from wallabagapi.wallabag import Wallabag
# settings
= 'http://localhost:8080'
my_host
async def main(loop):
= {'username': 'foxmask',
params 'password': 'mypass',
'client_id': 'myid',
'client_secret': 'mysecret',
'extension': 'pdf'}
# get a new token
= await Wallabag.get_token(host=my_host, **params)
token
= Wallabag(host=my_host,
wall =params.get('client_secret'),
client_secret=params.get('client_id'),
client_id=token,
token=params['extension'],
extension=session)
aio_sess
# initializing
async with httpx.AsyncClient() as client:
= 'https://foxmask.trigger-happy.eu'
url = 'foxmask\'s blog'
title
await client.post_entries(url, title, '', 0, 0)
= 'https://trigger-happy.eu'
url = 'Project TrigerHappy'
title
await wall.post_entries(url, title, '', 0, 0)
# get all the articles
= await wall.get_entries()
my_wallabag
= my_wallabag['_embedded']['items']
all_article
for article in all_article:
print(article['id'], article['title'])
# get the version of wallabag
= await wall.version
version print(f"version {version}")
# export one article into PDF
= await wall.get_entry_export(entry=1)
my_wallabag with open("foobar.pdf", "wb") as f:
f.write(my_wallabag)
if __name__ == '__main__':
= asyncio.get_event_loop()
loop loop.run_until_complete(main(loop))
this will give you something like this :
Testing :
Install Wallabag V2 on your own host like explain here http://doc.wallabag.org/en/v2/user/installation.html
Then run the development version (with make run)
Then create a client API like explain here http://doc.wallabag.org/en/v2/developer/api.html
this will give you something like this

Then replace the client_id / client_secret / login / pass to wallabag_test.py and run
python wallabag_test.py