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)
else:
# 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:
break
# 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)
I need my all time all members Member Attributes
lifetime_support_cents
Thank you for help @21echoes @monokrome @phildini @lynneatan @luizirber @tanabi @emosesPatreon
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
https://docs.patreon.com/#get-api-oauth2-v2-campaigns-campaign_id-members https://docs.patreon.com/#fetching-a-patron-39-s-profile-info
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.