npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@anitrack/patreon-wrapper

v1.5.3

Published

Universal Patron API v2 wrapper that simplifies their API usage in JavaScript

Downloads

355

Readme

🍊 Patreon Wrapper

💎 Universal Patron API v2 wrapper that simplifies their API usage in JavaScript

This package was previously used on AniTrack.co before switching to the payment gateway

Table of Contents

Install the package

$ npm install @anitrack/patreon-wrapper

Getting Started

import { Patreon } from '@anitrack/patreon-wrapper';

API Authorization

Where do I find Campaign ID? F12 your Patreon page and search for "campaign" then keep looking until you finds URL with campaign params that contains around 7 degits. That should be your Campaign ID

Patreon.Authorization({
    AccessToken: 'YOUR_API_V2_ACCESS_TOKEN',
    CampaignID: 'YOUR_CAPAIGN_ID',
});

Package Usage

Fetching every Patrons from the Campaign

const Patrons = await Patreon.FetchPatrons([
    'active_patron',
    'declined_patron',
    'former_patron',
]);

console.log(Patrons);

Patron object example

console.log(Patrons) from above

 [
    {
      displayId: '12345678',
      displayName: 'Username',
      emailAddress: '[email protected]',
      isFollower: false,
      subscription: {
        note: '',
        currentEntitled: {
          status: 'active_patron',
          tier: {
            id: '12345678',
            title: 'My First Tier'
          },
          cents: 500,
          willPayCents: 500,
          lifetimeCents: 1500,
          firstCharge: '2022-01-15 15:00:00.000',
          nextCharge: '2022-05-15 15:00:00.000',
          lastCharge: '2022-05-15 15:00:00.000'
        }
      },
      mediaConnection: {
        patreon: {
          id: '12345678',
          url: 'https://www.patreon.com/api/oauth2/v2/user/12345678'
        },
        discord: {
          id: '12345678',
          url: 'https://discordapp.com/users/12345678'
        }
      }
    },
    ...
]

Patreon Sandbox

This is great for development and working with sandbox patrons users. The sandbox patrons object will be exactly the same as real ones!

Adding Custom Patrons to the Sandbox

You can add as much sandbox patrons as you want

import { Sandbox } from '@anitrack/patreon-wrapper';

Sandbox.AddPatron({
    displayId: '123', // Patreon ID
    displayName: '123', // Patreon Username
    emailAddress: '[email protected]', // Patreon Email
    tier: { id: '123', title: 'Tier 1' }, // Current Tier
    cents: 500, // Current paying in cent 500 -> $5.00
    willPayCents: 500, // Next pay price
    lifetimeCents: 1500, // Total lifetime spent
    firstCharge: '2022-01-15 15:00:00.000', // ISO 8601 String date format
    nextCharge: '2022-05-15 15:00:00.000',
    lastCharge: '2022-04-15 15:00:00.000',
    patronStatus: 'active_patron',
    mediaConnection: {
        patreon: {
            id: '123',
            url: 'https://www.patreon.com/api/oauth2/v2/user/user_id',
        },
        discord: { id: '123', url: 'https://discord.com/users/user_id' },
    },
});

const Patrons = Sandbox.GetPatrons();

console.log(Patrons);

Get both Sandbox Patrons and Real Patrons

set second boolean argument "showSandboxPatrons" to true

const Patrons = await Patreon.FetchPatrons(
    ['active_patron', 'declined_patron', 'former_patron'],
    true
);

console.log(Patrons);

License

MIT