How to fetch tasks from Pipedrive using Python

Pipedrive is a comprehensive customer relationship management (CRM) platform that lets you track interactions with potential clients, organize contacts, dissect sales data for business strategy optimization, and more.

The platform collects various types of data that can be valuable to your product, and its tasks are no exception. You can post tasks to your business communications platform (e.g. Slack) to make them more visible; sync them with your ticketing tool when there’s issues at an account and additional stakeholders need to be looped in—and much more.   

To help facilitate these use cases, we’ll walk you through the process of collecting a list of tasks from Pipedrive by connecting to its API

Authentication

To access data from the Pipedrive API, authentication is required. This is performed using an API token which can be found in the Pipedrive web app settings. 

Once you have your API token, it needs to be included in every API request you make to Pipedrive. The token is added to the request headers as the value of the 'Authorization' key. 

How to retrieve tasks from Pipedrive

The script below first defines the base URL for the Pipedrive API, using the provided domain and API key. It then sets up the query parameters for the request, including the type of activity (task), the number of items to request (limit), and the starting point for the request (start). The script then enters a loop, where it sends a GET request to the Pipedrive API and processes the response. 

The response is parsed as JSON, and the tasks are extracted from the 'data' field of the response. The script prints out each task, and the loop continues as long as there are more items in the collection, as indicated by the 'more_items_in_collection' field in the 'additional_data'->'pagination' path of the response. For each iteration of the loop, the 'start' parameter is incremented by the 'limit' to fetch the next batch of tasks. 


import requests
import json
# Your Pipedrive domain and API key
DOMAIN = "your_domain"
API_KEY = "your_api_key"
# Base URL for the Pipedrive API
BASE_URL = f"https://{DOMAIN}.pipedrive.com/api/v1/activities?api_token={API_KEY}"
# Define query parameters
params = {
    "type": "task",
    "limit": 50,
    "start": 0
}
while True:
    response = requests.get(BASE_URL, params=params)
    data = response.json()
    tasks = data['data']
    for task in tasks:
        # Process task data here
        print(task)
    # Check for more items
    if not data['additional_data']['pagination']['more_items_in_collection']:
        break
    # Update the 'start' parameter for pagination
    params['start'] += params['limit']
    

Here’s a potential response from this API endpoint:


{
    "id": 1,
    "done": false,
    "type": "Call",
    "subject": "Follow up with client",
    "user_id": 123,
    "add_time": "2022-01-01T10:30:00Z",
    "due_date": "2022-01-02",
    "due_time": "10:00:00",
    "duration": "00:30:00",
    "type_name": "Phone Call",
    "company_id": 456,
    "owner_name": "John Doe",
    "active_flag": true,
    "update_time": "2022-01-01T11:00:00Z",
    "public_description": "Call to discuss project details",
    "assigned_to_user_id": 789,
    "marked_as_done_time": "2022-01-02T10:30:00Z",
    "created_by_user_id": 123
}

Looking to connect to more CRMs?

For those seeking to establish connections with multiple CRM systems, Merge's CRM Unified API provides an efficient solution. 

It allows you to access numerous CRM platforms, Pipedrive included, via a single API, thereby letting you offer multiple integrations while letting your engineers focus on your core product.

To learn more about Merge, you can request a demo.

But Merge isn’t just a Unified 
API product. Merge is an integration platform to also manage customer integrations.  gradient text
“It was the same process, go talk to their team, figure out their API. It was taking a lot of time. And then before we knew it, there was a laundry list of HR integrations being requested for our prospects and customers.” gradient text
“It was the same process, go talk to their team, figure out their API. It was taking a lot of time. And then before we knew it, there was a laundry list of HR integrations being requested for our prospects and customers.” gradient text
“It was the same process, go talk to their team, figure out their API. It was taking a lot of time. And then before we knew it, there was a laundry list of HR integrations being requested for our prospects and customers.” gradient text

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6
“It was the same process, go talk to their team, figure out their API. It was taking a lot of time. And then before we knew it, there was a laundry list of HR integrations being requested for our prospects and customers.”

Daniel Marashlian - Co-Founder & CTO

This is a link inside of a rich text

  • List item
  • List item
  • List item
  1. List item
  2. List item
  3. List item
Caption goes here
This is some text inside of a div block.
Table of contents
Add hundreds of integrations to your product through Merge’s Unified API
Get a demo
Just for you

How to fetch tasks from Pipedrive using Python

Jon Gitlin
Senior Content Marketing Manager
@Merge

Pipedrive is a comprehensive customer relationship management (CRM) platform that lets you track interactions with potential clients, organize contacts, dissect sales data for business strategy optimization, and more.

The platform collects various types of data that can be valuable to your product, and its tasks are no exception. You can post tasks to your business communications platform (e.g. Slack) to make them more visible; sync them with your ticketing tool when there’s issues at an account and additional stakeholders need to be looped in—and much more.   

To help facilitate these use cases, we’ll walk you through the process of collecting a list of tasks from Pipedrive by connecting to its API

Authentication

To access data from the Pipedrive API, authentication is required. This is performed using an API token which can be found in the Pipedrive web app settings. 

Once you have your API token, it needs to be included in every API request you make to Pipedrive. The token is added to the request headers as the value of the 'Authorization' key. 

How to retrieve tasks from Pipedrive

The script below first defines the base URL for the Pipedrive API, using the provided domain and API key. It then sets up the query parameters for the request, including the type of activity (task), the number of items to request (limit), and the starting point for the request (start). The script then enters a loop, where it sends a GET request to the Pipedrive API and processes the response. 

The response is parsed as JSON, and the tasks are extracted from the 'data' field of the response. The script prints out each task, and the loop continues as long as there are more items in the collection, as indicated by the 'more_items_in_collection' field in the 'additional_data'->'pagination' path of the response. For each iteration of the loop, the 'start' parameter is incremented by the 'limit' to fetch the next batch of tasks. 


import requests
import json
# Your Pipedrive domain and API key
DOMAIN = "your_domain"
API_KEY = "your_api_key"
# Base URL for the Pipedrive API
BASE_URL = f"https://{DOMAIN}.pipedrive.com/api/v1/activities?api_token={API_KEY}"
# Define query parameters
params = {
    "type": "task",
    "limit": 50,
    "start": 0
}
while True:
    response = requests.get(BASE_URL, params=params)
    data = response.json()
    tasks = data['data']
    for task in tasks:
        # Process task data here
        print(task)
    # Check for more items
    if not data['additional_data']['pagination']['more_items_in_collection']:
        break
    # Update the 'start' parameter for pagination
    params['start'] += params['limit']
    

Here’s a potential response from this API endpoint:


{
    "id": 1,
    "done": false,
    "type": "Call",
    "subject": "Follow up with client",
    "user_id": 123,
    "add_time": "2022-01-01T10:30:00Z",
    "due_date": "2022-01-02",
    "due_time": "10:00:00",
    "duration": "00:30:00",
    "type_name": "Phone Call",
    "company_id": 456,
    "owner_name": "John Doe",
    "active_flag": true,
    "update_time": "2022-01-01T11:00:00Z",
    "public_description": "Call to discuss project details",
    "assigned_to_user_id": 789,
    "marked_as_done_time": "2022-01-02T10:30:00Z",
    "created_by_user_id": 123
}

Looking to connect to more CRMs?

For those seeking to establish connections with multiple CRM systems, Merge's CRM Unified API provides an efficient solution. 

It allows you to access numerous CRM platforms, Pipedrive included, via a single API, thereby letting you offer multiple integrations while letting your engineers focus on your core product.

To learn more about Merge, you can request a demo.

“It was the same process, go talk to their team, figure out their API. It was taking a lot of time. And then before we knew it, there was a laundry list of HR integrations being requested for our prospects and customers.”

Name
Position
Jon Gitlin
Senior Content Marketing Manager
@Merge

Jon Gitlin is the Managing Editor of Merge's blog. He has several years of experience in the integration and automation space; before Merge, he worked at Workato, an integration platform as a service (iPaaS) solution, where he also managed the company's blog. In his free time he loves to watch soccer matches, go on long runs in parks, and explore local restaurants.

Read more

How to GET tasks from the Asana API in Python

Engineering

How to GET folders from the Dropbox API in Python

Engineering

10 critical REST API interview questions for 2025—answered

Engineering

Subscribe to the Merge Blog

Subscribe to the Merge Blog

Subscribe

Make integrations your competitive advantage

Stay in touch to learn how Merge can unlock hundreds of integrations in days, not years

Get a demo

Make integrations your competitive advantage

Stay in touch to learn how Merge can unlock hundreds of integrations in days, not years

Get a demo