Reader API
The Reader API is for building a media’s website or app: home and section pages, content, menus, search, reader login, subscriptions, ads… Base: https://<host>/api/media/v1. Full reference: Reader API.
What you need
| Item | Where to find it |
|---|---|
| Client ID and secret | Administration › ReaderHub › Clients (see) |
| Media ID | Administration › Publisher › Medias |
| Keys of menus, block configurations, templates, profile types, features | From the editorial team, or in API responses (assocs) |
Authenticating
Get a token
POST /api/media/v1/oauth/token
Content-Type: application/json
{
"grant_type": "client_credentials",
"client_id": "…",
"client_secret": "…",
"scope": "user"
}The response holds access_token (valid 1 hour), refresh_token (valid 90 days) and expires_in. The secret can also be sent as Authorization: Basic.
Call the API
Each call carries the token and, for a media’s data, the media ID:
GET /api/media/v1/overview
Authorization: Bearer <access_token>
x-omerlo-media-id: <media ID>Refresh the token
POST /api/media/v1/oauth/token
{ "grant_type": "refresh_token", "refresh_token": "…" }The previous token pair stays valid for 30 seconds, and a given refresh_token can only be used once.
Scopes
| Scope | Obtained with | Gives access to |
|---|---|---|
user | client_credentials or a reader login | Reading content and most operations |
profile | A reader login (authorization_code), if they have an account | Their account (/account/me), event registrations, invitations |
application | client_credentials, requested alone | Server-to-server operations: linking an account (/oauth/verify), sending email (/mail/send) |
Building pages
| Need | Call |
|---|---|
| Start: the media and its tree | GET /overview |
| Home page (root section) and its blocks | GET /sections/:root_section_id, then GET /blocks/:block_id |
| A section’s feed | GET /sections/:section_id/contents |
| A content | GET /contents/:id |
| Search | GET /contents/search?q=… |
| Menu | GET /menus/:key |
| List of fixed pages | GET /webpages |
| A fixed page, by its slug | GET /webpages/~/:slug (the slug may contain /: ~/about/team); GET /webpages/~ for the page whose slug is empty |
| Template of a fixed page built with the editor | GET /webpages/templates/:hash, with the template.hash returned by the page |
| Announcements | GET /announcements |
| Events, people, organizations, projects | GET /community/events, /community/people… |
| Digital editions | GET /distributions, GET /distributions/:id/releases |
| Advertising | GET /ads/random?format=300x250 (204 if none) |
| Sitemap | GET /sitemap/contents, /sitemap/events… |
Responses look like { "data": …, "meta": …, "assocs": { … } }: assocs gathers related items (a block’s contents, templates, sections, categories…), to avoid extra calls.
Logging readers in
List the providers
GET /oauth-providers returns the configured login providers (Google…).
Have the reader log in
Redirect the reader to the provider, with your return address (to be allowed in the provider’s console).
Exchange the code
POST /api/media/v1/oauth/token
{
"grant_type": "authorization_code",
"client_id": "…",
"code": "…",
"redirect_uri": "…",
"oauth_provider_id": "…"
}Link the account
With an application scope token, your server calls POST /oauth/verify with the reader’s verified address: Omerlo creates their account, or links the existing anonymous one. The reader then gets the profile scope.
Then: GET /account/me (their account), GET /account/me/entitlements (their access, by feature_key).
Subscriptions, votes, registrations
| Need | Call |
|---|---|
| The media’s mailing lists | GET /newsletter/mailinglists |
| Subscribe an address | POST /newsletter/subscriptions with email and mailinglist_id |
| The logged-in reader’s subscriptions | GET / DELETE /newsletter/subscriptions |
| Vote on a question | POST /contents/:id/votes (409 if already voted) |
| Register for an event | POST /community/events/:id/registration (profile scope) |
Cache
Public responses are cached by the delivery network for 60 seconds (sections, blocks, announcements) or 5 minutes (content, menus, categories, events, issues…). A change in Omerlo can therefore take a few minutes to show. Personal data (account, subscriptions) and ads are never cached.
Common errors
| Status | Usual cause |
|---|---|
400 missing header x-omerlo-media-id | Missing media header |
| 401 | Missing, expired or invalid token: refresh it |
403 incorrect authorization for the media | The media does not belong to the client’s organization |
403 Token missing scope | The token’s scope is not enough |