I need help to get 2 fields info of my all Patreon members

I need my all time all members Member Attributes lifetime_support_cents

So from all campaigns and all tiers

Plus to this I need their discord id or username - they can have multiple it is fine i need to get all

Discord has several i don’t know which is exactly users discord id or username


attributes > discord_id
social_connections > discord
attributes > discord_role_ids

Nothing else

I have been struggling to get these 2 info for hours

But nothing returns

Here my so far code. If you just tell me code of api_client fetch command i can do rest

I need all time, all campaigns and all tiers data

This below code returns all null data for all members. However I have over 500 discord ids in those members. I know because I was able to see them before their recent interface update.

import os
import json
import requests
from patreon import API, OAuth

# Patreon API authentication
client_id = "client_id"
client_secret = "client_secret"
access_token = "access_token"
refresh_token = "refresh_token"

api_client = API(access_token)

import os
import json

# Check if results.json exists
if os.path.exists("results2.json"):
    # Load data from results.json
    with open("results.json2", "r", encoding="utf-8") as file:
        all_patrons = json.load(file)
    # Fetch all patrons
    all_patrons = {}
    cursor = None

    # Get the campaign ID
    campaign_response = api_client.fetch_campaign()
    campaign_id = campaign_response.json_data['data'][0]['id']

    while True:
        pledges_response = api_client.fetch_page_of_pledges(campaign_id, 250, cursor=cursor)
        pledges = pledges_response.data()

        for pledge in pledges:
            included_members = pledge.document.json_data.get('included', [])
            data_members = pledge.document.json_data.get('data', [])
            data_members2 = pledge.document.json_data.get('included', [])

            for member in included_members + data_members + data_members2:
                if 'attributes' in member:
                    discord_id = member['attributes'].get('discord_id')
                    discord_username = member['attributes'].get('social_connections', {}).get('discord')
                    email = member['attributes'].get('email')
                    unique_key = f"{discord_id}_{discord_username}_{email}"

                    if unique_key not in all_patrons:
                        patron_data = {
                            "email": email,
                            "discord_username": discord_username,
                            "discord_id": discord_id
                        all_patrons[unique_key] = patron_data

        print(f"Fetching {cursor}")
        cursor = api_client.extract_cursor(pledges_response)
        if not cursor:

    # Convert the dictionary values to a list
    all_patrons = list(all_patrons.values())

    # Save data to results.json
    with open("results2.json", "w", encoding="utf-8") as file:
        json.dump(all_patrons, file, ensure_ascii=False)

This was responded to in the Discord. You need to connect Patreon’s Discord integration to your Discord and add Discord as a benefit to the specific tier from which you will check the users’ discord ids.