🐍 📓 Python API for Wallabag
Go to file
FoxMaSk 9a8a12219b upd repo 2022-10-19 15:10:32 +02:00
wallabagapi upd repo 2022-10-19 15:10:32 +02:00
.gitignore v1.3.2 2021-08-14 15:18:16 +02:00
.gitlab-ci.yml drop complexity 2021-08-15 21:51:21 +02:00
CHANGELOG Add CHANGELOG 2021-08-14 11:42:51 +00:00
CONTRIBUTING.md Update CONTRIBUTING.md 2021-08-14 20:09:34 +00:00
LICENSE upd requirements.txt 2021-08-14 13:40:16 +02:00
MANIFEST.in upd repo 2022-10-19 15:10:32 +02:00
README.rst upd repo 2022-10-19 15:10:32 +02:00
VERSION.txt upd repo 2022-10-19 15:10:32 +02:00
requirements-dev.txt upd repo 2022-10-19 15:10:32 +02:00
requirements.txt upd repo 2022-10-19 15:10:32 +02:00
setup.cfg upd repo 2022-10-19 15:10:32 +02:00
setup.py upd repo 2022-10-19 15:10:32 +02:00
wallabag.png wallabag post 2016-04-22 12:05:03 +02:00
wallabag_api_key.png create api client 2016-04-22 12:08:02 +02:00

README.rst

Wallabag API

Python API for Wallabag v2.4.2

Requirements :

  • httpx

Installation:

to get the project, from your virtualenv, do :

git clone https://git/afpy.org/foxmask/wallabagapi/

or

pip install wallabagapi

Creating a post :

  1. request the token, if you don't have it yet
  2. create the post
#!/usr/bin/env python

import httpx

from wallabagapi.wallabag import Wallabag
# settings
my_host = 'http://localhost:8080'


async def main(loop):

    params = {'username': 'foxmask',
              'password': 'mypass',
              'client_id': 'myid',
              'client_secret': 'mysecret',
              'extension': 'pdf'}

    # get a new token
    token = await Wallabag.get_token(host=my_host, **params)

    wall = Wallabag(host=my_host,
                    client_secret=params.get('client_secret'),
                    client_id=params.get('client_id'),
                    token=token,
                    extension=params['extension'],
                    aio_sess=session)

    # initializing
    async with httpx.AsyncClient() as client:

        url = 'https://foxmask.trigger-happy.eu'
        title = 'foxmask\'s  blog'

        await client.post_entries(url, title, '', 0, 0)

        url = 'https://trigger-happy.eu'
        title = 'Project TrigerHappy'

        await wall.post_entries(url, title, '', 0, 0)

        # get all the articles
        my_wallabag = await wall.get_entries()

        all_article = my_wallabag['_embedded']['items']

        for article in all_article:
            print(article['id'], article['title'])

        # get the version of wallabag
        version = await wall.version
        print(f"version {version}")

        # export one article into PDF
        my_wallabag = await wall.get_entry_export(entry=1)
        with open("foobar.pdf", "wb") as f:
            f.write(my_wallabag)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(loop))

this will give you something like this :

image

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

![Wallabag](https://gitlab.com/foxmask/wallabagapi/-/raw/master/wallabag_api_key.png)

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

python wallabag_test.py