Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Return Count of Zendesk Ticket View
import requests
from base64 import b64encode
ZENDESK_SUBDOMAIN = 'YOUR_SUBDOMAIN'
ZENDESK_VIEW_ID = 'YOUR_ZENDESK_VIEW_ID'
ZENDESK_EMAIL = 'YOUR_ZENDESK_EMAIL'
ZENDESK_API_TOKEN = 'YOUR_ZENDESK_API_TOKEN'
url = f'https://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/views/{ZENDESK_VIEW_ID}/count.json'
auth = f'{ZENDESK_EMAIL}/token:{ZENDESK_API_TOKEN}'
auth_encoded = b64encode(bytes(auth, 'utf-8')).decode('ascii')
headers = {
'Content-Type': 'application/json',
'Authorization': f'Basic {auth_encoded}'
}
data = requests.get(url, headers=headers).json()
view_count = data['view_count']['value']
output = {'view_count': view_count}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment