Including total_historical_amount_cents in list of pledges

I am currently trying to include the total_historical_amount_cents in the endpoint

https://www.patreon.com/api/oauth2/api/campaigns/CAMPAIGN_ID/pledges?include=patron.null

however I’m not having any luck. I tried

https://www.patreon.com/api/oauth2/api/campaigns/CAMPAIGN_ID/pledges?include=patron.null&fields%5Bpledge%5B=total_historical_amount_cents

but it doesn’t get me the total historical amount. https://www.patreon.com/api/oauth2/api/current_user?fields%5Buser%5B=like_count,comment_count works, taken directly from https://docs.patreon.com/#resources so I assume it would follow the same format for a pledge resource but something doesn’t seem to be right.

Any help would be appreciated, thank you.

You’ve encoded the square brackets incorrectly, it’s %5B and %5D. The D and B look similar, so it’s easy to get them confused. I recommend using a url encoder tool instead of manually encoding the characters, to avoid mistakes like that.

https://www.patreon.com/api/oauth2/api/campaigns/CAMPAIGN_ID/pledges?include=patron.null&fields%5Bpledge%5D=total_historical_amount_cents

Also, worth noting, when you specify any fields, you must specify all fields, meaning if you request an optional value like total_historical_amount_cents then you must also specify any others you wish to access, e.g: created_at, declined_since, has_shipping_address etc.

If you’re using a library (such as the official Patreon Java library, or the official Patreon Ruby library, or my unofficial Patreon PHP Library) the process of including default values alongside optional values will be handled for you.

1 Like

Aha I see. It works perfectly now, thank you for the speedy and concise reply!