Pricing
Log in

BY RUDDERSTACK TEAM

How to load data from Zendesk to PostgreSQL

01. Extract Data

  • 01. Extract Data
  • 02. Zendesk API Authentication
  • 03. Prepare Zendesk Data
  • 04. Load Data
  • 05. Update Data
  • 06. Extract Data

Try RudderStack for free

Sign up for RudderStack for free.

This post helps you with loading your data from Zendesk to PostgreSQL. If you are looking to get analytics-ready data without the manual hassle you can integrate Zendesk to PostgreSQL with RudderStack, so you can focus on what matters, getting value out of your business data.

Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.

Extract your data from Zendesk

Zendesk APIs are not specific to pulling data, Zendesk provides more than a hundred different APIs for you to integrate. So you can efficiently manage your users, enhance your team’s productivity and create seamless integrations. You can develop integrations or even enrich Zendesk with data from external sources. Zendesk API is a RESTful API that can be accessed through HTTP. You can interact with it by using tools like CURL or Postman or by using HTTP clients for your favorite language or framework.

A few suggestions:

  • Apache HttpClient for Java
  • Spray-client for Scala
  • Hyper for Rust
  • Ruby rest-client
  • Python http-client

Additionally, Zendesk offers a number of SDKs and libraries so you can access the API from your framework of choice without having to deal with the technicalities of HTTP. API clients are available for the following languages:

  • Ruby
  • Python
  • PHP
  • Java
  • .NET
  • Node.js
  • Clojure
  • Force.com
  • R

Zendesk API Authentication

Zendesk’s API is an SSL-only API, regardless of how your account is configured. You must be a verified user to make API requests. You can authorize against the API using either basic authentication with your email address and password, with your email address and an API token, or with an OAuth access token.

Zendesk rate limiting

The API is rate-limited. It only allows a certain number of requests per minute, depending on your plan and the endpoint. Zendesk reserves the right to adjust the rate limit for given endpoints to provide a high quality of service for all clients. The current limits are the following:

Pagination

By default, most list endpoints return a maximum of 100 records per page. You can change the number of records on a per-request basis by passing a per_page parameter in the request URL parameters. Example: per_page=50. However, you can’t exceed 100 records per page on most endpoints.

When the response exceeds the per-page maximum, you can paginate through the records by incrementing the page parameter. Example: page=3. List results include next_page and previous_page URLs in the response body for easier navigation:

JAVASCRIPT
{
"users": [ ... ],
"count": 1234,
"next_page": "https://account.zendesk.com/api/v2/users.json?page=2",
"previous_page": null
}

Endpoints and available resources

Their API exposes a large number of resources and endpoints that allow the user to interact with the platform in every possible way. Thus, it is possible to create new applications on top of the Zendesk platform, integrate external systems with it, and of course, pull data out of the platform. The most important resources are the following:

  • The tickets that your customers create through Zendesk.
  • Ticket events. Changes that have occurred to the tickets.
  • Organizations.
  • Users.
  • Ticket metrics. These are metrics related to your tickets.
  • Data related to the Net Promoter Score.
  • Articles

Let’s assume that we want to pull all the tickets we have on Zendesk to analyze them. To do that we need to perform a GET request to the appropriate end-point, like this:

JAVASCRIPT
GET /api/v2/incremental/tickets.json?start_time=1332034771
JAVASCRIPT
curl https://{subdomain}.zendesk.com/api/v2/incremental/tickets.json?start_time=1332034771 \
-v -u {email_address}:{password}

And a sample response:

JAVASCRIPT
Status: 200 OK
{
"end_time": 1383685952,
"next_page": "https://{subdomain}.zendesk.com/api/v2/incremental/tickets.json?start_time=1383685952",
"count": 1,
"tickets": [
{
"url": "https://{subdomain}.zendesk.com/api/v2/tickets/1.json",
"id": 2,
"created_at": "2012-02-02T04:31:29Z",
"generated_timestamp": 1390362285
},
]
}

A complete ticket object might contain the following fields:

The results of the Zendesk API are always in JSON format. The API offers you the opportunity to get very granular data about your accounting activities and use it for analytics and reporting purposes.


About Zendesk

Zendesk provides a cloud-based customer service platform that includes ticketing, self-service options, and customer support features. Zendesk focuses on improving the communication between your customers and your company. It brings all your customer communication into one place. The supported communication channels are:

  • Mail. Zendesk helps to organize all the emails you receive from your customers.
  • Social. You can connect your Facebook and Twitter account with Zendesk.
  • Voice. Take customer calls from within Zendesk.
  • Chat. Zopim Chat allows you to communicate with your customers from within your product.

Zendesk’s help desk software helps streamline customer support with time-saving tools like triggers and automation. And it’s intuitive, built with the experience of customer service and support desk agents in mind. Some important features of the ticketing system that Zendesk offers are:

  • It helps to Solve tickets better with teammates through a collaborative environment where information can be shared.
  • Get access to relevant information across teams. Zendesk comes with an internal Knowledge Base that allows agents to refer to information and processes without losing their place quickly.
  • Make everyone inside your company a support agent. With light agents, everyone inside your company can view tickets and make private comments.

Additionally, Zendesk offers a suite of analytics tools that will help you to get closer to your user through data. With these tools, you can:

  • Gain visibility into customers interactions
  • Measure your team’s performance
  • See the business impacts of great service

It is possible to track a large number of metrics related to your customers, support teams, and your business.

But in case that you would like to run some more engaged analysis with your Zendesk data, or fuse the customer support related data with data from other sources like your transactional database and logs, Zendesk exposes a rich ecosystem of APIs and tools that you can use to access and pull your data among other functionalities.

Zendesk Data Preparation for PostgreSQL

To populate a PostgreSQL database instance with data, first, you need to have a well-defined data model or schema that describes the data. As a relational database, PostgreSQL organizes data around tables.

Each table in PostgreSQL is a collection of columns with a predefined data type as an integer or VARCHAR. PostgreSQL, like any other SQL database, supports a wide range of different data types.

A typical strategy for loading data from Zendesk to the PostgreSQL database is to create a schema where you will map each API endpoint to a table. Each key inside the Zendesk API endpoint response should be mapped to a column of that table, and you should ensure the right conversion to a PostgreSQL compatible data type. For example, if you have an endpoint from Zendesk to return a value as String, you should convert it into a VARCHAR with a predefined max size or TEXT data type. Tables can then be created on your database using the CREATE SQL statement.

Of course, you will need to ensure that as the data types from the Zendesk API might change, you will adapt your database tables accordingly. There’s no such thing as automatic data type casting.

After you have a complete and well-defined data model or schema for PostgreSQL, you can move forward and start loading your data into the database.

About PostgreSQL

PostgreSQL, or simply Postgres, is one of the most well-known, popular, and well-supported databases. It can be used for different workloads, from simple single-machine applications to large-scale data warehousing scenarios.

PostgreSQL is ACID-compliant, transactional, and has one of the richest feature sets, including materialized views, triggers, foreign keys, stored procedures, and an architecture that encourages its extensibility.

Especially its last characteristic has made Postgres one of the most forked databases. Amazon Redshift is based on an earlier version of PostgreSQL as other database systems like Citus Data and Greenplum Database.

All the above characteristics of Postgres, a rich set of aggregation functions, the ability to define both simple and materialized views, the support for user-defined functions, and the ability to scale to pretty large datasets, make it an ideal database for analytics-related tasks.

Let’s see what it takes to populate and maintain a Postgresql database with data for analytics and business intelligence purposes.

Load data from Zendesk to PostgreSQL

Once you have defined your schema and you have created your tables with the proper data types, you can start loading data into your database.

The most straightforward way to insert data by Zendesk to the PostgreSQL database is by creating and executing INSERT statements. With INSERT statements, you will be adding data row-by-row directly to a table. It is the most basic and straightforward way of adding data to a table, but it doesn’t scale very well with larger data sets.

The preferred way for adding larger datasets into a PostgreSQL database is by using the COPY command. COPY is copying data from a file on a file system that is accessible by the PostgreSQL instance. In this way, much larger datasets can be inserted into the database in less time.

You should also consult the documentation of PostgreSQL on how to populate a database with data. It includes a number of very useful best practices on how to optimize the process of loading data into your PostgreSQL database.

COPY requires physical access to a file system in order to load data. Nowadays, with cloud-based, fully managed databases, getting direct access to a file system is not always possible. If this is the case and you cannot use a COPY statement, then another option is to use PREPARE together with INSERT, to end up with optimized and more performant INSERT queries.

Updating your Zendesk data on PostgreSQL

As you will be generating more data on Zendesk, you will need to update your older data on PostgreSQL. This includes new records together with updates to older records that, for any reason, have been updated on Zendesk.

You will need to periodically check Zendesk for new data and repeat the process that has been described previously while updating your currently available data if needed. Updating an already existing row on a Postgres table is achieved by creating UPDATE statements.

Another issue that you need to take care of is the identification and removal of any duplicate records on your database. Either because Zendesk does not have a mechanism to identify new and updated records or because of errors on your data pipelines, duplicate records might be introduced to your database.

In general, ensuring the quality of the data that is inserted in your database is a big and difficult issue, and PostgreSQL features like TRANSACTIONS can help tremendously, although they do not solve the problem in the general case.

The best way of loading data from Zendesk to PostgreSQL

So far, we just scraped the surface of what you can do with PostgreSQL and how you can load data into it. Things can get even more complicated if you want to integrate data coming from different sources.

Are you striving to achieve results right now?

Instead of writing, hosting, and maintaining a flexible data infrastructure, use RudderStack that can handle everything automatically for you.

RudderStack, with one click, integrates with sources or services, creates analytics-ready data, and syncs your Zendesk to PostgreSQL right away.

Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.

Get Started Image

Get started today

Start building smarter customer data pipelines today with RudderStack. Our solutions engineering team is here to help.

Customer Data Platform for Developers | RudderStack
HIPPA Compliant
SOC 2 TYPE 2Users love RudderStack on G2