The API
Outcome: a program holding a real OAuth2 token from your Wallabag, listing entries and adding a new one that Wallabag fetches and extracts itself — the whole flow run in this guide's lab.
Why an API at all
Everything a person does in the browser —
save, tag, archive, export — a program may
need to do: an extension saving the page
you are reading, a script importing a list
of addresses, a reader app syncing your
Unread list. Wallabag's REST API is that
door, at addresses under /api/, with API
documentation served by the instance
itself at /api/doc/ (the lab's developer
page linked to it).
Clients and tokens
Access is granted per client, not per
password. The lab created a client in the
web interface (driver
wallabag-lab/drivers/lab-api-client-and-entries.py,
transcript
wallabag-lab/transcripts/t04-api.txt):
GET /developer/client/create -> 200
POST /developer/client/create -> 200
Lab CLI client - #1
Client ID 1_2ru5obpp69ycookokgkcggs8w04kc0kcgg4gkkoo08ko0kwcgo
Client secret 4zikozyrj88w804ksoko4kccggg4cws8k4kwggo48k84g8c04k
Those are throwaway lab credentials for a lab instance that no longer matters, and they are printed here for the same reason the transcript keeps them: so the flow can be followed exactly. Your real client's secret is a real secret; treat it like a password.
With the client, the lab asked the token endpoint for an access token, using the password grant (your username and password, plus the client pair):
POST /oauth/v2/token -> 200
{"access_token":"MDM1ZmI2...","expires_in":3600,
"token_type":"bearer", ... "refresh_token":"MzgwNGI..."}
Tokens expire — this one after 3600 seconds — and the refresh token is how a client renews without asking for your password again.
Reading and writing entries
With the token sent as
Authorization: Bearer <token>:
GET /api/entries with Bearer token -> 200
entries total: 1 pages: 1
entry id=3 title='The Elmwood Community Newsletter — Spring Plant Swap Returns'
archived=0 starred=0 tags=[]
And the second fixture article was added through the API alone:
POST /api/entries (star chart article) -> 200
created id=4 title='Keeping a Paper Star Chart — A Beginner Guide to Night Notes'
status=200
Wallabag fetched and extracted it exactly
as for a browser save — the API changes
who asks, not what happens. Chapter 7's
tag, archive, and star changes were also
made through this API, with PATCH.
What the lab did not run
Other grants (authorization code, for
third-party services), token revocation
drills, the API's entry-exists and
mass-action endpoints, and any rate or
scale behaviour are documented-only: the
project's own API documentation, served
by your instance at /api/doc/, is the
reference for them.
Check: create a client, fetch a token, and
call GET /api/entries. If the response
lists your real entries as JSON, you hold
the API — and every client you will meet
in chapter 12 is a variation on this call.