Aggregate every Patron's avatar URL

I wish to fetch every Patron’s avatar URL, what’s the best of doing this? Is there a way to do it without authentication? Right now I’m using the authenticated campaign/pledges endpoint

Some data is exposed by the Patreon API when you’re not authenticated, that includes patron’s avatars, so it is possible to access all of the avatars for a campaign’s patrons without being authenticated. You can access the unauthenticated endpoints by not including api/oauth2 segment in the URL.

Requires authentication and exposes all data:

https://www.patreon.com/api/oauth2/api/campaigns/69658/pledges

Does not require authentication and exposes some data:

https://www.patreon.com/api/campaigns/69658/pledges

If you’re using PHP then you can try my Patreon PHP library which includes optional unauthenticated access, and has documentation with some examples that include extracting all avatars for a campaign’s patrons.

Examples > Display Patrons adapted for unauthenticated:

Step 1. Pick a creator, e.g: RumbleFrog
Step 2. Obtain their campaign ID by clicking “Become a Patron” and copy the value of the c parameter from the URL
Step 3. Create a new directory for your project
Step 4. Use composer to install Patreon PHP (composer require squid/patreon php-http/guzzle6-adapter)
Step 5. Create index.php with the following contents:

<?php

require __DIR__ . '/vendor/autoload.php';

use Squid\Patreon\Patreon;

// 'access_token' can be left as-is, because we're not using authenticated access it does not need to be valid
$patreon = new Patreon('access_token');

// Set the library to make unauthenticated requests so you can access (limited) data about any campaign
$patreon->useUnauthenticatedResources();

$campaign = $patreon->campaigns()->getCampaignWithPledges(1767001);

$avatars = $campaign->pledges->map(function ($pledge) {
    return $pledge->patron->thumb_url;
});

?>

<h1>Patrons</h1>
<ul>
  <?php foreach ($avatars as $avatar): ?>
    <img src="<?php echo $avatar; ?>">
  <?php endforeach; ?>
</ul>

That will produce the following:

Note: this code will run slowly for creators with many pledges because it has to make lots of requests to the Patreon API to get all of the pledges, therefore you should not run it when someone loads the page, instead you should run the code in the background to generate a cache of the data you want to use.

You can find a more complex example project using Patreon PHP here, which includes a step by step guide for implementing it.

Let me know if you need any other pointers :slight_smile:


If you’re not using PHP:

The Patreon API implements the JSON API standard so you should find a JSON API consumer in your language of choice, then make requests to aforementioned endpoints (iterating through all of the pages) and and extract the thumb_url from each patron entity.