APIs & Integrations

martinov
Member

How do I get number of tickets in given pipeline via HubSpot API

Hello, I'm working on a integration of an external web app with HubSpot.

 

I've managed to create contacts and tickets, and make association between them via the API, so now users of the external app can create support tickets by submitting a form.

 

Our next goal is to show a widget on the administrative dashboard of the app, with number of open and closed tickets.

 

I can't find information about this in the API documentation. I thought as a last resort we could use `GET /crm/v3/objects/tickets` or `POST /crm/v3/objects/tickets/search` to fetch all tickets in the pipeline with a cron job to get the numbers on a regular interval, but even this ugly solution is not possible because these endpints have pagination limits so after the number of tickets increases above 100 the results won't be accurate anymore. ("You can only request at most 100 objects in one request.")

 

Any hints and ideas welcome!

0 Upvotes
6 Replies 6
John
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

How do I get number of tickets in given pipeline via HubSpot API

Here is part of the documentation that should help:

The paging cursor token of the last successfully read resource will be returned as the paging.next.after JSON property of a paged response containing more results.

The response will include something like this with the results.

 

"paging": {
  "next": {
    "link": "?after=NTI1Cg%3D%3D",
    "after": "NTI1Cg%3D%3D"
  },
  "prev": {
    "before": "string",
    "link": "string"
  }
}

 

 

You need to create a function to run itself again until all results are returned. 



I like kudos almost as much as cake – a close second.

martinov
Member

How do I get number of tickets in given pipeline via HubSpot API

Thanks for the timely feedback, guys, I appreciate it!

 

Using the webhooks systems as suggested by @dennisedson looks like the most appropriate solution, but after a discussion with the product owner we've decided to drop this feature alltogether as the work required to develop it far outweights the value it is adding to our app.

 

On a side note, I understand how to use paging on an API, it's just not a good idea to fetch all tickets in the system when all you need is simply two numbers.

0 Upvotes
John
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

How do I get number of tickets in given pipeline via HubSpot API

wait, you only need 2? do you know the ticket IDs? because you can fetch individual tickets

/crm/v3/objects/tickets/{ticketId}



I like kudos almost as much as cake – a close second.

martinov
Member

How do I get number of tickets in given pipeline via HubSpot API

Um, no I don't need 2 tickets. Maybe I didn't express myslef in a clear manner, but I've just checked what I've written above and I it looks like I've never said that I want to fetch 2 tickets

 

I need two numbers - number of tickets in the pipeline, and number of resolved tickets. Just the stats, that is, nothing about the actual tickets.

 

Anyway, thanks for trying to help. We've dropped this feature from the scope, managers will have to live without this information in the dashbaord of our app.

0 Upvotes
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

How do I get number of tickets in given pipeline via HubSpot API

Hey @martinov 

 

I don't have a ton of experience with the API so I apologies if some of my quesions are rather obvious.

 

I'm curious about you're usecase and why 100 isn't enough?

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

How do I get number of tickets in given pipeline via HubSpot API

hey @martinov, I am wondering if webhooks might be the direction you should be headed.  There is a good knowledge base article on webhooks and workflows that might be what you want.

Here is the developer doc on webhooks as well

 

@Kevin-C  , @John , @derekcavaliero , what are you all thinking about this? 

 

Thanks!