Patreon v2 /campaigns/<ID>/posts only returns 20 OLDEST posts

I am sending GET to https://www.patreon.com/api/oauth2/v2/campaigns/<ID>/posts?fields[post]=url,title,content,published_at&sort[post]=-published_at. It only returns 20 posts, and the annoying part is that it is returning the oldest 20 posts. Is there any way to make it return all posts, or to return the newest 20 posts? Thank you.

This question is also relevant for me, did you find any ways to sort or walk through pages?

Yes, you have to get the cursor and request the next batch. Patreon WordPress does it. You can check its example here:

1 Like

Thank you for the comment and sorry for the late reply. I have tried POSTing to https://www.patreon.com/api/oauth2/v2/campaigns/${CAMPAIGN_ID}/posts?fields[post]=url,title,content,published_at&page[count]=2 and https://www.patreon.com/api/oauth2/v2/campaigns/${CAMPAIGN_ID}/posts?fields[post]=url,title,content,published_at&page[count]=1000, yet it always still returns only 20 posts. The solution I have landed on is to send POST requests to the links.next url again and again until there is no link provided in the responce.

Here is the relevant code in NodeJs for anyone in need


const axios = require('axios');
axios.defaults.headers.common['Authorization'] = `Bearer ${ACCESS_TOKEN}`;

let posts = [];
let url = encodeURI(
  `https://www.patreon.com/api/oauth2/v2/campaigns/${CAMPAIGN_ID}/posts?fields[post]=url,title,content,published_at`
);
while (true) {
  const res = await axios.get(url);
  posts.push(...pagePosts);
  if (!res.data.links?.next) break;
  url = res.data.links.next;
}

Yeah. That’s the way to do it. The next cursor.

Hello. I’m new here and I’m trying to figure out how to do something very similar to this. The problem is, my response looks no different whether I GET

https://www.patreon.com/api/oauth2/v2/campaigns/<ID>/posts?fields[post]=url,title,content,published_at&sort[post]=-published_at
or
https://www.patreon.com/api/oauth2/v2/campaigns/<ID>/posts

I want to see those post fields, but they don’t show up. The documentation implies this is a scope problem, but it also says creator access tokens have all V2 scopes and I’m using that access token in my request. So the way I’m interpreting the documentation, I shouldn’t have to include any scope in my GET request? Am I misunderstanding the documentation?

Here’s the actual GET request:

https://www.patreon.com/api/oauth2/v2/campaigns/<ID>/posts?fields%5Bpost%5D%3Durl%2Ctitle%2Ccontent%2Cpublished_at%26sort%5Bpost%5D%3D-published_at

Thanks for any help you can provide.

You need to use cursor to page through the next set of posts. Check out how the WP plugin does it:

Ah, see that’s not the problem, I understand that.

What I’m talking about is the actual response data, not the pagination: it doesn’t have url,title,content, or published_at in it.

Here’s how each element looks:


        {
            "attributes": {},
            "id": "11234962",
            "type": "post"
        },

How do I get each element to include url,title,content, and published_at?

This is my GET url: https://www.patreon.com/api/oauth2/v2/campaigns/<ID>/posts?fields%5Bpost%5D%3Durl%2Ctitle%2Ccontent%2Cpublished_at%26sort%5Bpost%5D%3D-published_at

Update: Apologies, but I figured out my issue: I was URL encoding the query string instead of just the brackets. Once I fixed that, they returned the content I expected.


maybe I’m wrong, but it looks like those parameters don’t do anything? At least the WordPress plug-in doesn’t acknowledge they exist. First it gets the post list, then it loops over each one and gets each individual post content one request at a time: patreon-wordpress/patreon_content_sync.php at b17ec94b1bb3b0c032e79bdd1561431e359c30ea · Patreon/patreon-wordpress · GitHub

I’m still confused about why @Eden4897 wrote that url that way. Did that have any effect for them?