Skip to main content

API keys and apps

Poly Community → Settings → Advanced → API lets another service or an app use the community through its REST API: read posts and members, post, reply and react. There are two ways in.

  • An API key is for a service of your own, such as a newsletter that lists the week posts or a script that posts an announcement. It acts as one member you choose.
  • An app is for something members use themselves, such as a mobile app or a bot of another site. Each member is asked, once, to let it act for them.

What either can reach is what the member it acts for can reach on the site, and no more. The settings, the team screens, payments, logging in and signing up are never reachable this way.

Making a key​

API keys: one key named Newsletter export acting as admin, read only, and the form for a new key
Settings → Advanced → API → API keys
  1. Name it after what uses it, so you know later which key to take back.
  2. Acts as: the username or email of the member it acts for. Left empty, it acts for you. A service that only reads is best given a member who sees no more than it needs.
  3. What it may do: a key reads by default. Tick May post, reply and react too to let it write as that member.
  4. Requests a minute: how often it may ask. Past that it is answered "Too many requests" until the minute is over.
  5. Make a key. The key is shown this once. Copy it into the service now: the site keeps only a fingerprint of it, so nobody can read it again, you included.

The service sends it with each request as a bearer token:

Authorization: Bearer poly_…

Each key is listed with whom it acts as, what it may do and when it was last used. Revoke stops it at once.

Adding an app​

Apps: the authorize and token addresses of the site, and the form to add an app with its name and the addresses it returns to
Settings → Advanced → API → Apps
  1. App name: members see it when they are asked.
  2. Addresses it returns to, one a line: where the app takes members back after they say yes. Only these are accepted.
  3. What it may do: read, or post, reply and react too.
  4. Add the app. It gets a client ID to use.

The app sends a member to the Authorize address shown on the card. The member logs in if they need to and is asked whether to let the app act for them. The app then trades the code it gets back at the Token address for an access token, valid for an hour, and a refresh token, valid for 90 days. This is OAuth 2 with an authorization code and PKCE, which most OAuth libraries speak.

Remove signs the app out for every member at once.

The API description​

The API description (OpenAPI) opens a document of every route a key or an app may use, in OpenAPI 3.1. Tools such as Postman, Insomnia or an OpenAPI code generator read it as it is.

Limits​

Every answer says how many requests are left in the minute, in its X-RateLimit-Limit and X-RateLimit-Remaining headers. A request past the limit is answered with status 429 and a Retry-After header.

WordPress application passwords (in each user profile) keep working as they always have, as their member.

The routes that stay the same from one version to the next are listed in Stable routes.