Patreon fetching data correctly only for few accounts

Hello everyone!
So on a site, I’m fetching the Patreon data of people that connect Patreon through API,

we are fetching the following:

The issue is that for some accounts works great, showing also the Tier name, etc…
For other accounts this is not working correctly, like the data is not correct, or there is some strange conflicts, any idea what could be?

Without more details on what incorrect data you’re seeing (duplicated responses versus data that doesn’t match what the Patreon site says, for instance) my first guess is that it’s a caching issue, either with the particular bundle you’re using or with your host and how it handles the API calls.

A second guess would be annual versus monthly subscribers.

A third guess would be patrons that have pledged but not been charged yet.

I had some significant fun getting the patreon-php bundle to work with my Symfony app, so much so I forked the bundle in order to implement bypasses for the bundle’s own cache.

Hello so here is some info I’m not getting correctly:

  1. Instead of “Active Patreon”, I see “Former Patreon” and Tier name is missing.

  2. Another patreon account for example is not showing “Active Patreon” or “Former Patreon” with the date “1970-01-01” and no Tier name.

  3. Some time I have “Active Patreon” and all data all correct but the Tier name is missing

  4. Some connected account are working fine fetching all correct data

Thanks a lot for your precious help @Zanaras I really appreciate

So, my own patreon only has a few patrons so my sample size to draw on is fairly small, but from what I’ve been able to make sense of between them and my own API issues (I’ve gone as far as forking the PHP bundle, for reference):

[patron_status] will either be Active Patron or Former Patron. If they haven’t been charged successfully at least once, they won’t show as an Active Patron. If a charge lapses after a successful one for whatever reason, then the member becomes a Former Patron. You can also get some weird results with annual patrons, if your Patreon is monthly subscription based. This can be better figured out by requesting the is_follower, last_charge_status, last_charge_date, next_charge_date fields. I’ll cover annual subs a bit more later.

If a user has no tier data, and you’re certain you’re requesting it, then they most likely made a custom pledge, and as such have no tier. If they decided to make a custom pledge, they didn’t request a tier, and as such have no tier. They should still have the fields will_pay_amount_cents and currently_entitled_amount_cents in their membership data though, which should let you work out what they should have access to, if you want them to have access without requesting a tier.

If neither Active nor Former Patron are showing up for patron_status then I’d check if they’re a follower by requesting and then checking the is_follower field.

1970-01-01 is the default time for a lot of unix/linux systems if you ask for Date(0), if I recall correctly, so it’s possible that you’re converting an empty JSON response from a date field sent by the API to a null, false, zero, or something equally zero-ish and passing that to a date interpreter.

As for annual accounts, these aren’t directly expressed by the API but they’ll show up as Active Patrons with either a next_charge_date a year after the last_charged_date or a next_charge_date of null if they downgraded from an annual after paying, a last_charged_date up to a year ago, and currently_entitled_amount_cents will probably be 12 times what their current tier is.

I’ve not yet seen an instance where the API returns incorrect data, but most of the bundles I’ve seen for interacting with it don’t actually request all the fields that are available.

A former patron would not have a current tier, so the tier info should not be coming in. If you would like to check historical pledge, there is a field for that already.

Check the pledge amounts of the active patrons that do not have a tier info - they may have made custom pledges by entering a manual $ amount.

For 1970 dates, you can look into Zanaras’ tip.

So to solve this issue instead of fetching the tier name I should fetch the amount like 10€ for example ? So even if they make a custom pledge we get anyway the info ?

currently_entitled_amount_cents would give you that info, yes. currently_entitled_tiers would give you the tiers which the user is entitled. Their $ values may be different from the tiers’ own values.

In API response in data attributes i get info like - email/name etc But how should i fetch status, current amount. I get array of objects that has multiple attributes but how would i know which one is related to current account.
Check the image attached-

I’m not quite sure what API URL you’re using for that request, but each member is a unique user instance within a campaign. Those are the objects that say a given user has a particular relationship to a campaign, and reflect everything from followers to current patrons.

While there are multiple ways to identify a particular user as a particular member ID, the simplest is to capture the data from a user identity request (usually fetch_user in the API packages) using a particular user’s access token. If you’re only interested in a user’s relation to a single campaign, then you don’t need to request any other scope than identity when they first “Log in with Patreon” to your site–this will ensure that when you use their access token afterwards, the only membership relation returned is that of that user’s membership to your campaign.

If you have to work through multiple campaigns, then you’ll need to do some cross comparisons between user memberships and campaign memberships in order to identify which user is which campaign member and grant them things accordingly.

Are you querying the members of your campaign, or are you querying the memberships of a patron from whom you got the relevant permission?