Possible to limit the number of fields returned by API calls? | Community
Skip to main content

Possible to limit the number of fields returned by API calls?

  • September 26, 2017
  • 11 replies
  • 0 views

The tickets APIs for example, seem to send all fields about the tickets increasing the JSON response size. If all I want are the ticket IDs and titles, is it possible to get only these?

11 replies

Stephen43
  • September 30, 2017

Hi Thameera, 

Thanks for reaching out to us! You can definitely pull that kind of specific information using the API but it'd require a more advanced API call. You can find all the relevant endpoints here: https://developer.zendesk.com/rest_api/docs/core/tickets

We also have an API developer console that may make making those calls easier: https://developer.zendesk.com/requests/new

If you're not comfortable writing the API scripts you'd need to get that kind of specific information i'd recommend using Insights reports to pull that kind of specific data. You can easily build a report of ticket IDs and subject lines. 

You can also export views as CSV files which would also give you ticket IDs and subject lines. 

I hope that helps but if you have any more specific questions please feel free to reach out to us at support@zendesk.com and we'd be happy to help! 


  • Author
  • October 5, 2017

Thanks Stephen. But can you link me to the exact endpoint? I was referring to the tickets API doc you mentioned, but couldn't find how to make a specific query like that or any examples. 

Or should I rather mail to support@zendesk.com?


Stephen43
  • October 6, 2017

Hi Thameera, 

Thanks for reaching back out!

I apologize for the confusion. There are not specific endpoints for this information you'd actually need to parse the data in your API script which is what I meant by it being a more complicated API call. 


  • Author
  • October 9, 2017

Right. So are there any examples for these complicated API calls I can find? I couldn't find where to start from the documentation.

Basically, I know how to query for tickets, but I don't know how to query and get only a limited number of fields.


Dwight
  • October 10, 2017

Greetings Thameera,

There isn't a way to only return ticket IDs and titles from the tickets endpoints. That would be an interesting piece of product feedback, but our API returns the complete ticket object and assumes that you're able to ignore the fields which aren't relevant to your needs. While this does make for a larger JSON response size, the trade-off here has been made in favor of simplicity. In terms of a tool to parse that data more easily after the fact, I've enjoyed working with jq - https://stedolan.github.io/jq/ . While it's not an official tool or formally supported, it may be useful to you nonetheless.

Depending on your use-case, it may be possible to create a View that would display those tickets. Within a view, you can specify which columns you'd like to see and execute that view via the api: https://developer.zendesk.com/rest_api/docs/core/views#execution to pull the tickets contained therein. One downside of this method is that archived tickets will not be returned by a view (closed tickets are automatically archived after 120 days).

If neither of these solutions works well for your needs, I would encourage you to either create a new post on our Product Feedback forum, or add your vote & use-case to this existing post: https://support.zendesk.com/hc/en-us/community/posts/213442067-Search-API-endpoint-option-that-allows-you-to-choose-which-ticket-fields-to-return This gives our Product Managers the best view as to which features are in high demand to help prioritize future development.

Thanks!


  • Author
  • October 11, 2017

Hi Dwight,

Thanks for confirming this. Earlier answers suggested that it's possible to do this with the API, that's why I was confused.

> assumes that you're able to ignore the fields which aren't relevant to your needs

Yeah, that's what I'm doing right now. I went ahead and upvoted the suggestion in feedback forum.

Thanks!


Dwight
  • October 11, 2017

Sorry for the confusion! Thanks for putting your vote in on this one.

Cheers :-D


  • May 8, 2019

I would love to see this implemented as well.  It is easy to ignore the extra data, but when you are searching for tickets or articles via the API, there are times where you just need the title, id and the url, and having the system return the full body and 20 other fields is a waste of time and resources retrieving data that is not needed.


Brett13
  • Community Manager
  • May 9, 2019

Thanks for sharing your feedback CERVISCustomerSupport!

I also encourage you to cross-post this in our Support Product Feedback topic. This will help provide visibility to our product managers and other users in need of a similar functionality.

Thanks again!


  • May 3, 2021

Was this ever implemented ? i am looking for limiting the fields for  "api/v2/search.json?query" its not authorizing me to see this post

https://support.zendesk.com/hc/en-us/community/posts/213442067-Search-API-endpoint-option-that-allows-you-to-choose-which-ticket-fields-to-return


Dwight
  • May 3, 2021

Hi Thameera,

This has not been built, but I encourage you to post on the Product Feedback Forums - if the post Brent linked above is no longer available, I recommend making a fresh post therein or searching for others who've requested something similar.

Dwight B. | Customer Advocate