Query Intercom data in Python — Intercom rest API

Sophia Yang, Ph.D.
2 min readAug 19, 2020

First, we need to get the authentication info from Intercom by creating a “New app”. Click “New app” in the Developer Hub page.

Then you should be able to see Client ID, Client secret, and access token in your app. Great, now we can use these info to access data in Python.

import requests
from requests.auth import HTTPBasicAuth
token = 'xxx'
ID = 'xxx'

Overview

To get a overview of the Intercom data, run:

data = requests.get('https://api.intercom.io/counts', auth = HTTPBasicAuth(token, ID))
data.json()

This will show you how many users/companies/leads/tags/segments you have in your Intercom data.

Query users

If you want to query users with a certain criteria, you might find the “search for contacts” API to be useful. Instead of using a GET request, here we need to use a POST request. For example, if you are interested in how many signups in a given timeframe, you can do the following:

query = {
"query": {
"operator": "AND",
"value": [
{
"field": "signed_up_at",
"operator": ">",
"value": datetime.datetime(2020,7,1).timestamp()
},
{
"field"…

--

--