APIs & Integrations

andrey1
Member

How to get the pages list with visits count info? (It works for blog-posts, but got error for pages)

Hi, (and sorry for my bad english...)
I tryed to get the blog-posts/pages list with the visits count.
I used the following url for blog-posts (it`s undocumented API capability and it works) :
https://api.hubspot.com/blogs/v3/blog-posts?limit=300&includeAnalytics=true
And saw that works:

{
  "limit":300,
  "objects":[
    {
      ...,
      "analytics":{"ctaClickRate":0.0,"ctaClicks":0,"ctaViews":0,"pageViews":1},
      "analyticsPageId":"5788581506",
      "analyticsPageType":"blog-post",
      ...
    }
  ],
  ...
}

But when I tryed to make the same with the "pages" using request:
https://api.hubspot.com/pages/v3/pages?limit=300&includeAnalytics=true
I got the following error:

{
  "status":"error",
  "message":"Any of the listed authentication credentials are missing",
  "correlationId":"1fee551d-34f2-48bb-a503-510b751f6737",
  "engagement":{
    "access_token":"Not engaged, access_token (<<<it-was-my-token-here>>>) doesn't exist! is missing",
    "shhkey-v1":"shhkey-v1 not engaged. Shhkey not found in the request header.",
    "hapikey":"hapikey not engaged. hapikey is not present in query params.",
    "internal-cookie":"internal-cookie not engaged. Cookie not found in the request.",
    "app-cookie":"app-cookie not engaged. App cookie is not present on the request.",
    "legacy-app-cookie":"legacy-app-cookie not engaged. Auth cookie is not present in the request."
  },
  "requestId":"38b9fac5cecb00e52988e689bdec9a25"
}

Do you have any ideas how to get the pages list with visits count info?

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to get the pages list with visits count info? (It works for blog-posts, but got error for pages)

Hi @andrey1,

The reason you're getting that error when trying to access the pages endpoint is because it's an internal-only endpoint used by the app. This is actually also true for the blog-posts endpoint; the fact that it isn't returning an error doesn't imply that external usage is supported.

Any endpoints with the api.hubspot.com domain are internal only and should not be used externally, since they're liable to be changed/deprecated at any time without notice. To pull stats on pages/blog posts, you should instead investigate the Analytics API:

Get Analytics data for specific objects

GET /analytics/v2/reports/:object_type/:time-period - Get analytics data for specific objects.

0 Upvotes