0

I'm trying to parse through every patron listed in my Patreon campaign. I've been taking code right off of the Patron API to do so, but I'm still getting an error. This is what I have

import os
import patreon

access_token = os.environ.get('ACCESS_KEY_PATREON')     # patreon access token, saved as an environment variable
api_client = patreon.API(access_token)                  # set up patreon client
campaign_response = api_client.fetch_campaign()
campaign_id = campaign_response.data()[0].id()

I'm getting this error:

campaign_id = campaign_response.data()[0]

AttributeError: 'dict' object has no attribute 'data'

Since this is right off the documentation, I have no idea what could be wrong. I've imported the Patreon library, but maybe I didn't set everything up?

ForceBru
  • 43,482
  • 10
  • 63
  • 98
  • 2
    When in doubt, `print(campaign_response)` and see what it looks like. Also, if you're indeed copying this "right off the documentation", - documentation could be outdated or buggy – ForceBru May 30 '21 at 21:41
  • Do you have the environment variable `ACCESS_KEY_PATREON` set with your Patreon access key? – accdias May 30 '21 at 21:47

0 Answers0