Filtering pledge history by event type

How would I go about filtering pledge history? I’m using this as a query:

crate::apis::patreon::get(
    "https://patreon.com/api/oauth2/v2/identity",
    &[
        ("include", "memberships.pledge_history"),
        ("fields[pledge-event]", "type,tier_id,tier_title,date"),
        ("filter[memberships][pledge_history][type]", "pledge_create,pledge_upgrade,pledge_downgrade,pledge_delete"),
    ],
)

However, this doesn’t actually work. The fields are retrieved just fine, but I’m getting all types of pledge events. I’ve tried various combinations in filter - filter[pledge-event][type], filter[pledge-event.type], among others.

If maybe I’m looking at the wrong thing, what I am aiming to do is derive a set of entitlements based on when a user was subscribed and at what time they were subscribed to each tier, so unsubscribed users can still download their old stuff. The downloads themselves are through my own site.

You will need to iterate the events and sort them out at your side as there isnt a particular mechanism to filter individual pledge events at the api.

This is potentially memory-intensive as I am expecting to handle tens of thousands of individual patrons. Is there any pagination available here within those event lists, or only at the members level when accessing /api/oauth2/v2/campaigns/{campaign_id}/members ?

The pagination happens at the members level. You should be able to request a large amount of members while calling that endpoint. However if you request a very large amount of members, the pledge events included will be cut to the last ~100 or so. If you request a lower amount of member listings, then more pledge events should come.

To get around memory issues, you can request only the minimum fields that you need. That will trim down the return. You can even request the member resource without any field but the pledge events.

Handling a very large number of patrons should not be a problem since the api limits provide for that and many creators and partners already do it.