API v2 - How to get Benefits belonging to a Tier?

Hello, I’m using the Patreon API.

I could get Tiers and Benefits that belongs to Campaigns using https://www.patreon.com/api/oauth2/v2/campaigns?include=tiers,benefits

Is there any APIs to get Benefits belonging to a Tier?

You can try getting the benefits resource for the campaign:

https://docs.patreon.com/#benefit

Thanks for your reply. As I stated above, I know how to get all benefits of a campaign and what I need to know if there is any APIs to get benefits attached to a tier. Could you please give me more details on how to get the Benefit Relationships (tiers array[Tier]: The Tiers the benefit has been added to.) in your document link?

There isn’t a specific api for this. What you would need to do would be to get a campaign’s tiers, and match the tiers to other resources like benefits over the ids.

https://docs.patreon.com/#tier
https://docs.patreon.com/#benefit
I don’t see any Tier attributes related to Benefits (ids) and any Benefits attributes related to Tier (ids) so I don’t know how to match them over the ids as you said. Could you please give me more details on how to match them?

Those are resources that you can request while making a query over whichever major resource endpoint that they are related to. They should be listed in the includes section in any major resource endpoint. Case in point - the tier resource is an include of the /campaign top level endpoint:

https://docs.patreon.com/#get-api-oauth2-v2-campaigns-campaign_id

It could get Tiers and Benefits of a campaign, what I need to know is how to match them over the ids. I don’t see any Tier attributes related to Benefits (ids) and any Benefits attributes related to Tier (ids).

So you need to match benefits to tiers, but you arent able to get tier ids in the benefits details. Is that correct?

Yes it is. I need to know how to get Tier Ids in a Benefit or get Benefit Ids in a Tier.

Try requesting the tiers that the benefit has been added to by requesting the tiers as a relationship of the benefit:

https://docs.patreon.com/#benefit

Back to this question:
Could you please give me more details on how to get the Benefit Relationships (tiers array[Tier]: The Tiers the benefit has been added to.) in your document link?

When you are making the call, add to the includes benefits.tiers while requesting the benefits. Something like…

campaigns?include=tiers,benefits.tiers,creator,goals

…should work.

It works. Many thanks.

1 Like