Checking if a user is currently subscribed to a campaign


#1

Is there a way to find out if a user (which I have previously authenticated through OAuth) is currently subscribed to my campaign without having to get their user data, then make a separate request for all my pledges and go through each of them searching for their username? I’d expect that to be one of the most used applications of the Patreon API so it seems weird to me that there would only be this roundabout way.

Forgive me if the terms I used are unclear - I tried to avoid using Patreon’s nomenclature (patron, creator, pledge etc.) because I’m not sure what exactly they mean (e.g. a pledge. What is it? A subscription or a payment? The former exists only once per user-creator pair and vanishes if the user stops supporting the creator, the latter is permanent and a new one is created for every user-creator pair every month).


#2
  • A User is an account
  • A Creator is the User who owns the campaign
  • A Patron is a User who subscribes to the campaign
  • A Pledge is a subscription to a campaign

Patron and Creator refer to a relationship between a Campaign and User, i.e a user can be both a Creator and a Patron of different campaigns. Every Campaign has a Creator, every Pledge has a Patron.

The Patreon API does not expose any individual payment records however it does expose a number of properties on the Pledge resource that can be used to determine payment status. For example declined_since is null unless the latest payment attempt has been declined, and if so it is the date of the last payment attempt, total_historical_amount_cents is the total value of all successful payments in cents, less any refunds.

As I understand it based on the documentation (and not personal use) you should be able to retrieve the user’s pledges to the campaign of the OAuth client creator by using the pledges-to-me scope. That scope should, I believe, allow you to access the user’s pledges to the campaign of the OAuth client creator when making a request to current_user. Fetching a patron’s profile info displays the following example response:

{
  "data": {
    "attributes": {
      [...]
    },
    "id": "0000000",
    "relationships": {
      "pledges": {
        "data": []
      }
    },
    "type": "user"
  }
}

The documentation states that by default the pledge relationship is included so if you’re not receiving that data you could try specifying pledge in the includes parameter. If that doesn’t work, an employee will probably be along shortly to clarify things for you.