Typescript Oauth library for the V2 Patreon API with:
- Support for Creator access tokens and Oauth tokens.
- Client with methods for calling every endpoint, both resource and webhook endpoints
- Methods to create a webhook server
- Typescript types that strongly reflect your query for raw or normalized responses.
const query = buildQuery.campaign([])({ campaign: ['title']})
const payload = await client.fetchCampaign(query)
// ^? { data: { attributes: { title: string } }, ... }
const campaign = await client.normalized.fetchCampaign(query)
// ^? { title: string, id: string, type: Type.Campaign }
npm install patreon-api.ts
pnpm add patreon-api.ts
yarn add patreon-api.ts
Supported Patreon api: v2
The default API version for this package is 2
and might change in major versions.
[!CAUTION] This package does not include v1 of the Patreon API and starts with API v2. The sections in the Patreon documentation are prefixed by
APIv2:
. The Oauth flow, introduction and sections below sorting are related to all versions.
When the default API version is changed, old versions will still receive updates. You can not import this module by API version since it is unlikely that Patreon will release a new version any time soon.
To read more about how to use this library, go to the documentation. Still doubting if this library has everything you need related to the Patreon API? Compare all libraries yourself.
Compatibility
To check for compatibility with this package, look if your platform:
- has the globals:
AbortController
,setTimeout
,clearTimeout
,fetch
,URL
andURLSearchParams
- for node.js:
v18
or higher - for Cloudflare workers: enable Node.js
- for node.js:
- supports
ES2020
- supports
createHmac
of thenode:crypto
module (to verify Patreon webhook requests)
[!WARNING] This is a server-side API & Oauth package and requires your application tokens. Make sure you do not share or expose your tokens or run this code client-side.
Tip: the Patreon API blocks browser requests, so choose a backend to handle Oauth2 request and return the data to your frontend.
This library is used to create the Patreon OpenAPI for the patreon-api-spec
repository. The stable spec is also available on the API documentation of this library.
- Commonly used routes and community resources
- Example webhook server: Cloudflare worker and express.js server
- Example Node.js server: ESM and CJS
Detailed changes are listed for each release in the changelog.
For upcoming releases, see the roadmap for planned changes.
See the code of conduct and the contributing guide for how to contribute. You can also support the development by writing guides, posts and templates or by funding the maintainers.
Copyright (c) 2023-present, ghostrider-05