Text analytics

I am trying to access all our historical conversations in Freshdesk in order to do text analytics in python.
However, when I call the Freshdesk API, it only seems to return 30 tickets.
I am also not sure whether there is a simpler way of coding this or if it is necessary to pull a list of all ticket ids and then iterate through the list to get all the conversation body texts each as a sperate API call.

Please see screenshots below:
image

Sorry I see the images did not pull through, please see below:
‘’’
url = BASE_URL + “/tickets”

response = requests.get(url, auth=(API_KEY, PASSWORD))

if response.status_code == 200:
tickets = json.loads(response.content)
for ticket in tickets:
print(ticket[‘id’])
else:
print(“Failed to fetch tickets.”)
‘’’

‘’’
url = BASE_URL + “/tickets/20/conversations”

response = requests.get(url, auth=(API_KEY, PASSWORD))

if response.status_code == 200:
conversations = json.loads(response.content)
print([conversation.get(‘body_text’, ‘’) for conversation in conversations])
else:
print(f"Failed to retrieve conversations for ticket {ticket_id}. Status code: {response.status_code}")
‘’’

Hi @Hannam,

Welcome to the community :tada:

You can /api/v2/tickets/[id]?include=conversations use this query to get the conventions of a ticket.

And also if you would like to fetch all of them, then you would paginate through the module to fetch the expected result.

Hope that helps!
Thank you.

Hey @Hanna

also a warm welcome from my side.

What you have to consider when iterating through all tickets is, that you have to use the updated_since filter and can only fetch 30.000 tickets with pagination.
So if you have more, you have to use the updated_since accordingly.

Look here for more details.

Best
Tom

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.