Getting popular pages in Confluence via GraphQL

I’m trying to get popular pages in Confluence Cloud via GraphQL (the use case is to display n recently created/updated pages in my Confluence Cloud instance).
For that I’m using this query:
https://<my_instance>.atlassian.net/cgraphql?q=FeedPopularFeedQuery
Body:

query FeedPopularFeedQuery($first: Int, $after: String) {
  popularFeed(first: $first, after: $after) {
    nodes {
     // (cut)
    }
  }
}

Variables:

{
  "first": 5,
  "after": "MTY1ODg0NDAwMDAwMCMy"
}

Only three correct items out of 5 are returned in the result set, I assume the problem is in the after parameter. Currently I’m just using one grabbed from the Developer Tools. Can you please share how to correctly generate it? I’ve noticed over the course of time only middle part is changed, I assume in has some now timestamp embedded into it.

2 Likes

@TylerBrown I know this operation is not a part of an official documentation, but maybe you can still provide some input please? Thanks in advance.

Hi,

What you are trying to hit is actually the internal graphql implementation used by confluence, not the public one. So it has different types and isn’t supported by being called by apps or external uses. GraphQL Gateway Instead you would want to use our public APIs which live here, and can be called via Forge apps.

Either way we would love to hear more about your use case. Are you building a new app? We could see about adding these popular feed APIs to our future work plan for adding more APIs for public consumption.

Thanks!
Tyler

2 Likes

Unfortunately public APIs do not have endpoints we need, so we are planning to use some internal ones. Hence the question).

Yes, we are building an app that has some analytics capabilities, and for starters we want to get most of the information that is available on ‘Home’ page in CC web UI like starred pages, recent pages, popular/followed pages. For basic features we use REST API, for advanced ones GraphQL might be an option. For analytics - I guess we need to get creative, because even CC web UI does not have lists of the most viewed/edited/commented pages anywhere. I know existing fellow integration connects Google Analytics to track some of those.

even CC web UI does not have lists of the most viewed/edited/commented pages anywhere

It actually does, in Premium and Enterprise editions only). Could work for us, but there is no API to underlying site, space and page analytics features :frowning:.