Skip to main content

Gets Json donation information from the DonorDriveAPI

Project description

Usage

Importing

Find the link to your API link for your donations (For help finding your link go to Donor Drive API: How tos). Import the module into your python project as normal

[!IMPORTANT] Currently the import is fairly messy, and has to be imported a little confusingly, see the example code below

Creating a new Donation Manager class

After importing the DonationTracker class can be initialized like any other python object, requiring a url to your DonorDrive donation API Link

Optionally, after the URL, a second string giving the name for the json file. The format is <PATH>/<FILENAME>.json inputting any other filetype into the method raises a TypeError

Using the get_new_donations() method

Any DonationTracker object can get the get_new_donations() method. Calling this method requests the donation Json from the Donor Drive API for the participant's link

The method calls the API, which returns JSON data. It then checks if there is already a local donos.json. The return from this method is an array of the format [number of new donations, new donations json]

The Json returned in the array is formatted as a python dictionary inside of an array this is a little strange, however it is a byproduct of Python's built-in Json Handler Module. This format allows interchangability between Json (for file handling) and usage in python. It is essential the formatting is not changed, as doing so may lead to malformed JSON file output.

An example of the output of this is as follows

[1, [{'displayName': 'Johnpaul Shields', 'donorID': '79D83C498A38FBB3', 'links': {'recipient': 'https://www.extra-life.org/participants/566838', 'donate': 'https://www.extra-life.org/participants/566838/donate'
}, 'isRegFee': False, 'eventID': 562, 'createdDateUTC': '2026-02-20T21:14:29.923Z', 'recipientName': 'Johnpaul Shields', 'recipientImageURL': 'https://donordrivecontent.com/extralife/images/$avatars$/constituen
t_E4B21B29-DD36-DBF8-79D83C498A38FBB3.jpg?v=1771442940259', 'message': 'Test Dono 2', 'participantID': 566838, 'amount': 1.0, 'donorIsRecipient': True, 'avatarImageURL': 'https://donordrivecontent.com/extralife
/images/$avatars$/constituent_E4B21B29-DD36-DBF8-79D83C498A38FBB3.jpg?v=1771442940259', 'donationID': '235890E3214394E3'}]]

The method then writes the new data to the json file allowing the method to be used again. When no new donations are given, the method returns [0, '{}'] of which '{}' is an empty json list

Using the get_last_cached_donation() method

Just like the get_new_donations() method, the get_last_cached_donation() method returns JSON data. However, it does not return an array like get_new_donations() does. Instead it returns just raw cached donation data, and if there is none it returns a '{}'. The biggest difference between this method and get_new_donations() is that get_last_cached_donation() does NOT make an API request; Instead it checks if there is already a json file with the donation data and if there is, returns the latest donation. This was added as a way to get the "cached" donation data without making an API request.

An example of the output of this method is as follows:

  • If there is a file
{'displayName': 'Johnpaul Shields', 'donorID': '79D83C498A38FBB3', 'links': {'recipient': 'https://www.extra-life.org/participants/566838', 'd
onate': 'https://www.extra-life.org/participants/566838/donate'}, 'isRegFee': False, 'eventID': 562, 'createdDateUTC': '2026-02-20T21:14:29.92
3Z', 'recipientName': 'Johnpaul Shields', 'recipientImageURL': 'https://donordrivecontent.com/extralife/images/$avatars$/constituent_E4B21B29-
DD36-DBF8-79D83C498A38FBB3.jpg?v=1773862012806', 'message': 'Test Dono 2', 'participantID': 566838, 'amount': 1.0, 'donorIsRecipient': True, '
avatarImageURL': 'https://donordrivecontent.com/extralife/images/$avatars$/constituent_E4B21B29-DD36-DBF8-79D83C498A38FBB3.jpg?v=1773862012806
', 'donationID': '235890E3214394E3'}
  • If there is no file
{}

Using the get_cached_donation() method

Just like the get_cached_donations() method, the get_cached_donation() method returns JSON data (not in an array) and doesn't make an API request. It takes in one argument (an integer) donation_index and returns the donation in the cached data at that index. After a recent push, get_last_cached_donation() now uses this method at donation_index of 0. If the index is not an integer or is out of bounds, the method gives an error in the standard output and returns an empty json '{}'

Example of Usage

from donationmanager import DonoTracker

url = 'https://www.extra-life.org/api/1.6/participants/minismeef/donations'
donotracker = DonoTracker.DonationTracker(url)

if __name__ == '__main__':
    new_donations = donotracker.get_new_donations()
    print(new_donations)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

donationmanager-2.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

donationmanager-2.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file donationmanager-2.0.0.tar.gz.

File metadata

  • Download URL: donationmanager-2.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.9-arch1-1

File hashes

Hashes for donationmanager-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6859d1f993db8cd3adbf58b0ec54327f6cbb370bb5f3b49b76ef2bb432277a2e
MD5 bc6a15d3833be107348cca79cffcb6a6
BLAKE2b-256 87b5c6acb788ead4b0d518e5e8b7463fd14c870fe7aa943675fac9c7514df0d0

See more details on using hashes here.

File details

Details for the file donationmanager-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: donationmanager-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.19.9-arch1-1

File hashes

Hashes for donationmanager-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1177b9886969388214fc2fdcd1c5226243e04db3070d672625ef2cf05336dff5
MD5 8e0b4d0614bbdfcf82cc9a985045f863
BLAKE2b-256 16d391216da393d0d6f30b88a5b1aa09db31a2af094cd91364fd3d80edc35659

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page