This project connects to the Zendesk API to retrieve tickets (and their comments), then exports the data to a CSV file. It:
- Uses environment variables instead of hard-coding credentials (for security)
- Handles pagination to fetch tickets in batches
- Fetches additional comments for each ticket, beyond the initial description
- Saves the final data to a timestamped CSV file
There are two main ways to download the code from this repository: zendesk_exporter_project under the GitHub user rodbland2021.
- Open this repository on GitHub:
https://github.com/rodbland2021/zendesk_exporter_project - Click the green "Code" button near the top-right
- Select "Download ZIP"
- Unzip the downloaded file on your computer, and you will have all the files from this repository
This method is simplest if you just want a one-time copy without needing Git or version control.
If you want the full Git history (to pull future updates or contribute back), clone the repository using Git.
- Install Git (if you haven't already)
- Open a terminal (Command Prompt, PowerShell, or Git Bash)
- Navigate to the folder where you want the repository stored. For example:
cd C:\path\to\your\folder
- Run:
git clone https://github.com/rodbland2021/zendesk_exporter_project.git
This creates a new folder named zendesk_exporter_project containing all the files, commit history, and branches.
- Install GitHub Desktop from desktop.github.com
- Open GitHub Desktop and sign in to your GitHub account
- Go to File → Clone repository
- Under the URL tab, enter:
https://github.com/rodbland2021/zendesk_exporter_project.git - Choose a local path (the folder on your machine where you'd like to store the repository)
- Click "Clone" to download it
Install them with:
pip install requests pandas tqdmOr, if you have a requirements.txt file:
pip install -r requirements.txtYour script relies on three environment variables for Zendesk credentials:
-
ZENDESK_SUBDOMAIN
- The subdomain is the part before
.zendesk.com - Example: If your Zendesk URL is
https://mycompany.zendesk.com, thenmycompanyis the subdomain
- The subdomain is the part before
-
ZENDESK_EMAIL
- The email address associated with your Zendesk account
-
ZENDESK_API_TOKEN
- The API token you generate from your Zendesk admin settings
- macOS/Linux (bash/zsh):
export ZENDESK_SUBDOMAIN="mycompany"
export ZENDESK_EMAIL="my-email@example.com"
export ZENDESK_API_TOKEN="my-api-token"
python main.py- Windows (Command Prompt):
set ZENDESK_SUBDOMAIN=mycompany
set ZENDESK_EMAIL=my-email@example.com
set ZENDESK_API_TOKEN=my-api-token
python main.py- Windows (PowerShell):
$env:ZENDESK_SUBDOMAIN="mycompany"
$env:ZENDESK_EMAIL="my-email@example.com"
$env:ZENDESK_API_TOKEN="my-api-token"
python main.pyIf you use a .env file with python-dotenv, remember to add .env to your .gitignore to prevent committing credentials.
- Install dependencies (see above)
- Set your environment variables as shown
- Run your script (for example,
python main.py) - When prompted, enter the number of tickets to export or press Enter to export all
Once complete, the script will create a CSV file with the format:
zendesk_tickets_YYYYMMDD_HHMMSS.csv
This file will contain all ticket details and comments.
- Missing credentials: If the script reports missing
ZENDESK_SUBDOMAIN,ZENDESK_EMAIL, orZENDESK_API_TOKEN, verify that you've set them correctly (see "Setting Environment Variables" above) - Accidental credential commit: If you accidentally commit an API token to your repository, immediately revoke the token in Zendesk and remove it from your Git history
- Rate limits: Zendesk imposes rate limits; the script uses small
time.sleepdelays to avoid hitting them too quickly - Further help: Refer to Zendesk's API documentation for more details on endpoints, parameters, and best practices