How to load data from Pipedrive to Google BigQuery

Blendo Team

Pipedrive is a sales management tool designed to help small sales teams manage intricate or lengthy sales processes successfully. What if I want to get more data-driven and analyse the CRM data you have on Pipedrive to my BI or custom analytics stack or to my data warehouse like BigQuery? How can I analyse the data generated with Pipedrive as part of your CRM customer data? This guide is going to provide you with a clear picture about how to load data from Pipedrive to Google BigQuery.  We will use Pipedrive’s API to access and extract customer related data and load it into Google BigQuery for further analysis.

You will need to write the code to get the data and make sure that this process will run every time new data are generated. Alternatively, you can use products like Blendo that can handle this kind of problems automatically for you.

What is Pipedrive?

Pipedrive is a sales management tool designed to help small sales teams manage intricate or lengthy sales processes successfully. Based on a philosophy of activity-based selling, it ensures teams focus on the actions that drive deals to close. Some of the differences of Pipedrive to other CRM and sales management platforms are the following:

  • Dedicated Sales Management Platform. CRM is more generic. Pipedrive instead focuses more on offering a great experience for sales teams specifically.
  • Pipeline focused. Instead of focusing on numbers and metrics, Pipedrive focuses on the sales pipeline which is the overall process that your company will be running for acquiring new customers.
  • Optimised data experience. While CRMs are all about user data, Pipedrive is built in such a way that the minimal time is spent on data entry, so your salesmen can focus on selling instead of maintaining data.

Pipedrive focuses more on smaller teams and companies and it tries to address the unique problems that these might have, although it can also be found inside bigger companies. Such a great product couldn’t be built without a solid back-end and an excellent API. This API will be also used in this article to show how we can pull out valuable data from Pipedrive.

How to load data from Pipedrive to Google BigQuery

How to load data from Pipedrive to Google BigQuery

What is Google BigQuery?

BigQuery is the data warehousing solution of Google. It’s part of the Google Cloud Platform and it also speaks SQL like Redshift does. Queries are executed against append-only tables using the processing power of Google’s infrastructure.

How to Load data from Pipedrive to Google BigQuery

Load data from Pipedrive to Google BigQuery

It is also fully managed and is offered as a service over the cloud. You can interact with it through its web UI, using a command line tool while a variety of client libraries exist so you can interact with it through your application.

How to Extract my data from Pipedrive?

Pipedrive exposes its complete platform to developers through their API. As a Web API following the RESTful architecture principles, it can be accessed through HTTP.

As a RESTful API, interacting with it can be achieved by using tools like CURL or Postman or by using HTTP clients for your favourite language or framework. A few suggestions:

Pipedrive API Authentication

Pipedrive API Authentication is API-Key based. You acquire an API Key from the platform and you can use it to securely authenticate to the API. All the calls are executed over secure HTTPS.

Pipedrive rate limiting

Rate limiting is is considered per API token. API allows performing 100 requests per 10 seconds.

Every API response includes the following headers:

  1. X-RateLimit-Limit: the amount of requests current API token can perform for the 10 seconds window.
  2. X-RateLimit-Remaining: the amount of requests left for the 10 seconds window.
  3. X-RateLimit-Reset: the amount of seconds before the limit resets.

In case the limit is exceeded for the time window, the Pipedrive API will return an error response with HTTP code 429 and Retry-After header that will indicate the amount of seconds before the limit resets.

Endpoints and available resources

Pipedrive exposes a large number of endpoints from which we can interact with the platform. These endpoints can be used to both execute commands like adding a new person to our contact list but also to pull data from it. A unique characteristic of the Pipedrive API is that for many of the resources a companion resource exists which manages the custom fields that you might have created for the resource. In this way, maximum flexibility is offered to the users of the platform. The list of available resources follows:

  • Activities: Activities are appointments, tasks and events in general that can be associated with a deal and your sales pipeline.
  • Activity Fields: custom fields created for your activities.
  • Activity Types: user defined types for your activities
  • Authorization: Authorization objects can be fetched without an API token but using an email and password.
  • Currencies: Supported currencies which can be used to represent the monetary value of a Deal, or a value of any monetary type custom field.
  • Deals: Deals represent ongoing, lost or won sales to an Organization or to a Person.
  • Deal Fields: DealFields represent the near-complete schema for a Deal in the context of the company of the authorized user.
  • Email Messages: EmailMessages represent e-mail messages sent or received through Pipedrive designated e-mail account.
  • Email Threads: EmailThreads represent e-mail message threads which contain individual e-mail messages.
  • Files: Files are documents of any kind (images, spreadsheets, text files, etc) that are uploaded to Pipedrive
  • Filters: Each filter is essentially a set of data validation conditions.
  • Goals: Goals help your team meet your sales targets.
  • Mail Messages: MailMessages represent mail messages that are being synced with Piperive using the 2-way sync or the Smart Email BCC feature.
  • MailThreads: MailThreads represent mail threads which contain individual mail messages.
  • Notes: Notes are pieces of textual (HTML-formatted) information that can be attached to Deals, Persons and Organizations.
  • Note Fields: Custom fields for Notes.
  • Organizations: Organizations are companies and other kinds of organizations you are making Deals with.
  • Organization Fields: OrganizationFields represent the near-complete schema for an Organization in the context of the company of the authorized user.
  • Persons: Persons are your contacts, the customers you are doing Deals with
  • Person Fields: Custom fields for persons.
  • Pipelines: Pipelines are essentially ordered collections of Stages.
  • Products: Products are the goods or services you are dealing with.
  • Product fields: ProductFields represent the near-complete schema for a Product.
  • Stages: Stage is a logical component of a Pipeline, and essentially a bucket that can hold a number of Deals.
  • Users: Users are people with access to your Pipedrive account.

For a detail list of all endpoints together with a way to make requests to them without a client to see the data they return, if you have a Pipedrive account. Please check here.

It is clear that with such a rich platform and API the data that can be pulled out of Pipedrive are both valuable and come in large quantities. So, let’s assume that we want to pull all the persons out of Pipedrive to use the associated data for further analysis. To do so we need to make a GET request with your favourite client, to the Persons’ endpoint like this.

GET https://api.pipedrive.com/v1/persons?start=0&api_token=YOUR_KEY

The response headers and the actual response will look like the following:

{
    "server": "nginx",
    "date": "Tue, 06 Sep 2016 15:46:38 GMT",
    "content-type": "application/json",
    "transfer-encoding": "chunked",
    "connection": "keep-alive",
    "x-frame-options": "SAMEORIGIN",
    "x-xss-protection": "1; mode=block",
    "x-ratelimit-limit": "100",
    "x-ratelimit-remaining": "99",
    "x-ratelimit-reset": "10",
    "access-control-allow-origin": "*"
}

 

{
    "success": true,
    "data": [
        {
            "id": 1,
            "company_id": 1180166,
            "owner_id": {
                "id": 1682699,
                "name": "Kostas",
                "email": "costas.pardalis@gmail.com",
                "has_pic": true,
                "pic_hash": "39bf355364aacbde4fdfed3cef8a4589",
                "active_flag": true,
                "value": 1682699
            },
            "org_id": null,
            "name": "Fotiz",
            "first_name": null,
            "last_name": "Fotiz",
            "open_deals_count": 0,
            "closed_deals_count": 0,
            "participant_open_deals_count": 0,
            "participant_closed_deals_count": 0,
            "email_messages_count": 0,
            "activities_count": 0,
            "done_activities_count": 0,
            "undone_activities_count": 0,
            "reference_activities_count": 0,
            "files_count": 0,
            "notes_count": 0,
            "followers_count": 1,
            "won_deals_count": 0,
            "lost_deals_count": 0,
            "active_flag": true,
……

Inside the response there will be an array of object swith each one representing one Person as it is represented in Pipedrive. Please note that all data are serialised in JSON.

After you have successfully pulled your data from the Pipedrive API you are ready to extract and prepare them for Google BigQuery. Of course, the above process is only for one of the available resources, if you would like to have a complete view of all the available data then you will have to create a much complex ETL process including the majority of the resources that Pipedrive has. Alternatively, you can check how Blendo which can simplify the whole process and you can have your Pipedrive data available for analysis in a matter of a few minutes.

How can I prepare my data to be sent from Pipedrive to Google BigQuery?

Before you load your data into BigQuery, you should make sure that it is presented in a format supported by it, so for example if the API you pull data from returns XML you have to first transform it into a serialisation that BigQuery understands. Currently two data formats are supported:

You also need to make sure that the data types you are using are the ones supported by BigQuery, which are the following:

  • STRING
  • INTEGER
  • FLOAT
  • BOOLEAN
  • RECORD
  • TIMESTAMP

for more information please check the Preparing Data for BigQuery page on the documentation.

Load Data from Pipedrive to Google BigQuery

If you want to load data from Pipedrive to Google BigQuery, you have to use one of the following supported data sources.

  1. Google Cloud Storage
  2. Sent data directly to BigQuery with a POST request
  3. Google Cloud Datastore Backup
  4. Streaming insert
  5. App Engine log files
  6. Cloud Storage logs

From the above list of sources, 5 and 6 are not applicable in our case.

For Google Cloud Storage, you first have to load your data into it, there are a few options on how to do this, for example you can use the console directly as it is described here and do not forget to follow the best practices. Another option is to post your data through the JSON API, as we see again APIs play an important role in both the extraction but also the loading of data into our data warehouse.. In it’s simplest case it’s just a matter of one HTTP POST request using a tool like CURL or Postman. It should look like the following example.

POST /upload/storage/v1/b/myBucket/o?uploadType=media&name=myObject 
HTTP/1.1 Host: www.googleapis.com 
Content-Type: application/text 
Content-Length: number_of_bytes_in_file 
Authorization: Bearer your_auth_token your Pipedrive data

and if everything went ok, you should get something like the following as a response from the server:

HTTP/1.1 200 Content-Type: application/json { "name": "myObject" }

Working with Curl or Postman, is good only for testing, if you would like to automate the process of loading your data into Google Bigquery, you should write some code to send your data to Google Cloud Storage. In case you are developing on the Google App Engine you can use the library that is available for the languages that are supported by it:

  1. Python
  2. Java
  3. PHP
  4. Go

If you are using one of the above languages and you are not coding for the Google App Engine, you can use it to access the Cloud Storage from your environment. Interacting such a feature rich product like Google Cloud Storage can become quite complicated depending on your use case, for more details on the different options that exist you can check Google Cloud Storage documentation. If you are looking for a less engaged and more neutral way of using Cloud Storage, you can consider a solution like Blendo.

After you have loaded your data into Google Cloud Storage, you have to create a Load Job for BigQuery to actually load the data into it, this Job should point to the source data in Cloud Storage that have to be imported, this happens by providing source URIs that point to the appropriate objects.

The previous method described, used a POST request to the Google Cloud Storage API for storing the data there and then load it into BigQuery. Another way to go is to do a direct HTTP POST request to BigQuery with the data you would like to query. This approach is similar to how we loaded the data to Google Cloud Storage through the JSON API, but it uses the appropriate end-points of BigQuery to load the data there directly. The way to interact with it is quite similar, for more information can be found on the Google BigQuery API Reference and on the page that describes how to load data into BigQuery using POST. You can interact with it using the HTTP client library of the language or framework of your choice, a few options are:

 

The best way to load data from Pipedrive to Google BigQuery and possible alternatives

So far we just scraped the surface of what can be done with Google BigQuery and how to load data into it. The way to proceed relies heavily on the data you want to load, from which service they are coming from and the requirements of your use case. Things can get even more complicated if you want to integrate data coming from different sources. A possible alternative, instead of writing, hosting and maintaining a flexible data infrastructure, is to use a product like Blendo that can handle this kind of problems automatically for you.

Blendo integrates with multiple sources or services like databases, CRM, email campaigns, analytics and more. Quickly and safely move all your data from Pipedrive to Google BigQuery and start generating insights from your data.