Skip to main content

Hatchbuck.com CRM API bindings for Python

Project description

Build status Python versions Software license Test coverage report

This python package provides an easy to use python module to interact with the hatchbuck.com API.

Installation

The easiest way to install hatchbuck is with pip

$ pip install hatchbuck

Basic Usage

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.search_email('bashar.said@vshn.ch')
pp.pprint(profile)

You can get your Hatchbuck API key at https://app.hatchbuck.com/account/setting#WebAPI when logged in

Examples

Search for one email address

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.search_email('bashar.said@vshn.ch')
pp.pprint(profile)

Output

   {'addresses': [{'city': 'Zürich',
               'country': 'Switzerland',
               'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
               'id': 'Q0NjajF2U1lTWnBHM1hjRFlnQzhzMHZ2UUxLY2d6a1JaU3Nicm5hRTN6azE1',
               'state': 'ZH',
               'street': 'Neugasse 10',
               'type': 'Work',
               'typeId': 'SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1',
               'zip': '8005'}],
'campaigns': [],
'company': 'VSHN AG',
'contactId': 'SUFYbGdOaEQ0cWR2N1JfV183UFNBSDllTktCc3E3OWRsN09qaW4tU3JqbzE1',
'customFields': [{'name': 'Comments', 'type': 'MText', 'value': ''},
                 {'name': 'Invoiced', 'type': 'Number', 'value': ''},
                 {'name': 'Language', 'type': 'Text', 'value': ''},
                 {'name': 'working at company since',
                  'type': 'Text',
                  'value': '1.1.2018'},
                 {'name': 'company size', 'type': 'Text', 'value': '25'},
                 {'name': 'Birthday', 'type': 'Date', 'value': ''}],
'emails': [{'address': 'bashar.said@vshn.ch',
            'id': 'S2lIY2NOS2dBRnRCamEyQUZxTG00dzhlYjAxUU9Sa3Z5ZFVENGVHTG1DODE1',
            'type': 'Work',
            'typeId': 'VmhlQU1pZVJSUFFJSjZfMHRmT1laUmwtT0FMNW9hbnBuZHd2Q1JTdE0tYzE1'}],
'firstName': 'Bashar',
'instantMessaging': [],
'lastName': 'Said',
'phones': [{'id': 'OHh4U0ZWc3FNVXVBQVF4cjdsak9McWc4TVppZlF4NklrNmZfSnBhaDZwQTE1',
            'number': '+(414) 454-5 53 00',
            'type': 'Work',
            'typeId': 'QTBncHV0dndnaGNnRVMzLTR0SGtFRmRvZjdqNm4zcVphQi1XX1Z2MXVtRTE1'}],
'referredBy': '',
'salesRep': {'id': 'VGpwQTRGTmw4MExVODl1b1BmXzBodTBwWnZXS2dUZzVvSkJKZUx4UlFpdzE1',
             'username': 'aarno.aukia'},
'socialNetworks': [{'address': 'https://twitter.com/bashar_2018',
                    'id': 'S1pEM2NMWlhmZ1VUcDhTUWVvQy1kU21xMjlSbDg5Z3piMERVbEFsam42azE1',
                    'type': 'Twitter',
                    'typeId': 'ZGRlMHpBaXY3M05YUGc4a0pIY3lRdUFKN1JYaDd2VEphbzhSRkdzM2x4bzE1'},
                   {'address': 'https://www.linkedin.com/in/bashar-said-729a54156/',
                    'id': 'Tzd0TTBueVQzS09JQVZTLUxiUUxUT25VMmVvT0dua2txc2NHZkNkNEg5VTE1',
                    'type': 'LinkedIn',
                    'typeId': 'Q2dJTVQ1NW9UYzhJeUd4ckI0dWFNWkpLOUxyTXVGUFVjQlZYbVM2ZlI4bzE1'}],
'source': {'id': 'MHZFdHZqcWVXT1IyNHZGYlM1RGppWVVJcGc3aHgtU3lXRWtfQmFXN0lCODE1',
           'name': 'vshn.ch'},
'status': {'id': 'UE9zMy1abnhnNUJQWnVORE5BQzNicUFWQ3huLXF2eGlSdlIyYVFmVXh4UTE1',
           'name': 'Employee'},
'subscribed': True,
'tags': [],
'temperature': {'id': 'UTI0Nm14TlB4SmRkdVNLMjNWQWgwR2R2TjhySE1US1RtVEQ0T24tRWtFbzE1',
                'name': 'Hot'},
'timezone': 'W. Europe Standard Time',
'title': 'DevOps Engineer Intern',
'website': [{'id': 'bktodFBCalVCU2J6aFhjaXc5UVZkUHM5OHFnd0ZuQmdJTTU0cDRScm1KSTE1',
             'websiteUrl': 'https://vshn.ch'}]}

Search for the first and last name

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.search_name('bashar', 'said')
pp.pprint(profile)

Output

We get the same results When we search by email address because the firstname and lastname(bashar, said) belong to the         same email address(bashar.said@vshn.ch)

Search within a list of email addresses

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.search_email_multi(['sgdhfgfdgh@fdvd.com', 'bashar.said@vshn.ch', ...])
pp.pprint(profile)

Note: The emails must be in list form, and the search process stops getting the first match

Output

We found a profile with his email address: ‘bashar.said@vshn.ch’

  {'addresses': [{'city': 'Zürich',
               'country': 'Switzerland',
               'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
               'id': 'Q0NjajF2U1lTWnBHM1hjRFlnQzhzMHZ2UUxLY2d6a1JaU3Nicm5hRTN6azE1',
               'state': 'ZH',
               'street': 'Neugasse 10',
               'type': 'Work',
               'typeId': 'SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1',
               'zip': '8005'}],
'campaigns': [],
'company': 'VSHN AG',
'contactId': 'SUFYbGdOaEQ0cWR2N1JfV183UFNBSDllTktCc3E3OWRsN09qaW4tU3JqbzE1',
'customFields': [{'name': 'Comments', 'type': 'MText', 'value': ''},
                 {'name': 'Invoiced', 'type': 'Number', 'value': ''},
                 {'name': 'Language', 'type': 'Text', 'value': ''},
                 {'name': 'working at company since',
                  'type': 'Text',
                  'value': '1.1.2018'},
                 {'name': 'company size', 'type': 'Text', 'value': '25'},
                 {'name': 'Birthday', 'type': 'Date', 'value': ''}],
'emails': [{'address': 'bashar.said@vshn.ch',
            'id': 'S2lIY2NOS2dBRnRCamEyQUZxTG00dzhlYjAxUU9Sa3Z5ZFVENGVHTG1DODE1',
            'type': 'Work',
            'typeId': 'VmhlQU1pZVJSUFFJSjZfMHRmT1laUmwtT0FMNW9hbnBuZHd2Q1JTdE0tYzE1'}],
'firstName': 'Bashar',
'instantMessaging': [],
'lastName': 'Said',
'phones': [{'id': 'OHh4U0ZWc3FNVXVBQVF4cjdsak9McWc4TVppZlF4NklrNmZfSnBhaDZwQTE1',
            'number': '+(414) 454-5 53 00',
            'type': 'Work',
            'typeId': 'QTBncHV0dndnaGNnRVMzLTR0SGtFRmRvZjdqNm4zcVphQi1XX1Z2MXVtRTE1'}],
'referredBy': '',
'salesRep': {'id': 'VGpwQTRGTmw4MExVODl1b1BmXzBodTBwWnZXS2dUZzVvSkJKZUx4UlFpdzE1',
             'username': 'aarno.aukia'},
'socialNetworks': [{'address': 'https://twitter.com/bashar_2018',
                    'id': 'S1pEM2NMWlhmZ1VUcDhTUWVvQy1kU21xMjlSbDg5Z3piMERVbEFsam42azE1',
                    'type': 'Twitter',
                    'typeId': 'ZGRlMHpBaXY3M05YUGc4a0pIY3lRdUFKN1JYaDd2VEphbzhSRkdzM2x4bzE1'},
                   {'address': 'https://www.linkedin.com/in/bashar-said-729a54156/',
                    'id': 'Tzd0TTBueVQzS09JQVZTLUxiUUxUT25VMmVvT0dua2txc2NHZkNkNEg5VTE1',
                    'type': 'LinkedIn',
                    'typeId': 'Q2dJTVQ1NW9UYzhJeUd4ckI0dWFNWkpLOUxyTXVGUFVjQlZYbVM2ZlI4bzE1'}],
'source': {'id': 'MHZFdHZqcWVXT1IyNHZGYlM1RGppWVVJcGc3aHgtU3lXRWtfQmFXN0lCODE1',
           'name': 'vshn.ch'},
'status': {'id': 'UE9zMy1abnhnNUJQWnVORE5BQzNicUFWQ3huLXF2eGlSdlIyYVFmVXh4UTE1',
           'name': 'Employee'},
'subscribed': True,
'tags': [],
'temperature': {'id': 'UTI0Nm14TlB4SmRkdVNLMjNWQWgwR2R2TjhySE1US1RtVEQ0T24tRWtFbzE1',
                'name': 'Hot'},
'timezone': 'W. Europe Standard Time',
'title': 'DevOps Engineer Intern',
'website': [{'id': 'bktodFBCalVCU2J6aFhjaXc5UVZkUHM5OHFnd0ZuQmdJTTU0cDRScm1KSTE1',
             'websiteUrl': 'https://vshn.ch'}]}

We did not find a profile with an email address: ‘sgdhfgfdgh@fdvd.com’

Create profile

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.create({
    "firstName": "Hawar",
    "lastName": "Afrin",
    "title": "Hawar1",
    "company": "HAWAR",
    "emails": [
        {
            "address": "bashar.said.2018@gmail.com",
            "type": "work",
        }
    ],
    "phones": [
        {
            "number": "0041 76 803 77 34",
            "type": "work",
        }
    ],
    "status": {
        "name": "Employee",
    },
    "temperature": {
        "name": "Hot",
    },
    "addresses": [
        {
            "street": "Langäcker 12",
            "city": "wettingen",
            "state": "AG",
            "zip": "5430",
            "country": "Schweiz",
            "type": "work",
        }
    ],
    "timezone": "W. Europe Standard Time",
    "socialNetworks": [
        {
            "address": "'https://twitter.com/bashar_2018'",
            "type": "Twitter",
        }
    ],
})
pp.pprint(profile)

Output

  {'addresses': [{'city': 'Wettingen',
               'country': 'Switzerland',
               'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
               'id': 'eDZNV2d4Q1ZIR09UN2p1UlhzclVCdTM0LU81UW5TZzZmU05vLUtuVzdoMDE1',
               'state': '',
               'street': 'Langäcker 13',
               'type': 'Home',
               'typeId': 'M1ZkLXI3UnJqUWxUVDNFZUZ3MW5MdG5KSGZuN0lVemNDcXNLdzgzbjBDVTE1',
               'zip': '5430'},
              {'city': 'Zürich',
               'country': 'Switzerland',
               'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
               'id': 'OEFPUzJBeTdaWlVhU3FDR194dEk3NU8xTThxakZuQXV4aE9obHM3SVdKTTE1',
               'state': 'ZH',
               'street': 'Neugasse 10',
               'type': 'Work',
               'typeId': 'SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1',
               'zip': '8005'},
              {'city': 'Wettingen',
               'country': 'Switzerland',
               'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
               'id': 'QnZnaFlQYlhnU0NZX0x6NHZMVTJoaU9HV1AzS0dybjdOd0JDc1AwVlVXMDE1',
               'state': '',
               'street': 'Langäcker',
               'type': 'Home',
               'typeId': 'M1ZkLXI3UnJqUWxUVDNFZUZ3MW5MdG5KSGZuN0lVemNDcXNLdzgzbjBDVTE1',
               'zip': '5430'}],
'campaigns': [],
'contactId': 'TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1',
'customFields': [{'name': 'Comments', 'type': 'MText', 'value': ''},
                 {'name': 'Invoiced', 'type': 'Number', 'value': ''},
                 {'name': 'Language', 'type': 'Text', 'value': ''},
                 {'name': 'working at company since',
                  'type': 'Text',
                  'value': ''},
                 {'name': 'company size', 'type': 'Text', 'value': ''},
                 {'name': 'Birthday', 'type': 'Date', 'value': '1/1/1984'}],
'emails': [{'address': 'bashar.said.2018@gmail.com',
            'id': 'M2FaYWpqY1pBMldGeVpYYW11cXRpTUw2NndOcFJsUXIzZGI2VC1JRmdSYzE1',
            'type': 'Work',
            'typeId': 'VmhlQU1pZVJSUFFJSjZfMHRmT1laUmwtT0FMNW9hbnBuZHd2Q1JTdE0tYzE1'}],
'firstName': 'Hawar',
'instantMessaging': [],
'lastName': 'Afrin',
'phones': [{'id': 'MVhxaXBHdlRWOWdLX05FbHF6ZnczMERGVTMyWWRkZ0xsSFFQcXVNYW5NTTE1',
            'number': '0041 76 803 77 34',
            'type': 'Work',
            'typeId': 'QTBncHV0dndnaGNnRVMzLTR0SGtFRmRvZjdqNm4zcVphQi1XX1Z2MXVtRTE1'}],
'referredBy': '',
'salesRep': {'id': 'VGpwQTRGTmw4MExVODl1b1BmXzBodTBwWnZXS2dUZzVvSkJKZUx4UlFpdzE1',
             'username': 'aarno.aukia'},
'socialNetworks': [{'address': "'https://twitter.com/bashar_2018'",
                    'id': 'Y0c2YktIcG1kakt4RTJiRkh3NVVnYzNqejdkUkVrQVRkUE0tUVQ3TUpPdzE1',
                    'type': 'Twitter',
                    'typeId': 'ZGRlMHpBaXY3M05YUGc4a0pIY3lRdUFKN1JYaDd2VEphbzhSRkdzM2x4bzE1'}],
'status': {'id': 'UE9zMy1abnhnNUJQWnVORE5BQzNicUFWQ3huLXF2eGlSdlIyYVFmVXh4UTE1',
           'name': 'Employee'},
'subscribed': True,
'tags': [{'id': 'Y0Y4VFRhbDZSZFl2eENuYWU4M2s4Q3FsNjExTk5ldjdVOFdWU29ZRy1UTTE1',
          'name': 'new tag',
          'score': 1}],
'temperature': {'id': 'UTI0Nm14TlB4SmRkdVNLMjNWQWgwR2R2TjhySE1US1RtVEQ0T24tRWtFbzE1',
                'name': 'Hot'},
'timezone': 'W. Europe Standard Time',
'title': 'Hawar1',
'website': [{'id': 'MW5tUm5IcVVDYmhVZ0lSVndJenBxbDZra1ZwVEcxQXBVWDB6NkVCUWNRODE1',
             'websiteUrl': 'http://002.powercoders.org/students/bashar-said/index.html'},
            {'id': 'eG91X0tVcWU2a1A3dVg1b2JKQ1MyWGwzaGFjX1Q5RGRSNng3OE9XbGxBNDE1',
             'websiteUrl': 'http://002.powercoders.org/students/alan-omar/index.html'}]}

Profile updated

For example, we want to update the addresses in the previous profile

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.update('TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1', {
    "firstName": "Hawar",
    "lastName": "Afrin",
    "title": "Hawar1",
    "company": "HAWAR",
    "emails": [
        {
            "address": "bashar.said.2018@gmail.com",
            "type": "work",
        }
    ],
    "phones": [
        {
            "number": "0041 76 803 77 34",
            "type": "work",
        }
    ],
    "status": {
        "name": "Employee",
    },
    "temperature": {
        "name": "Hot",
    },
    "addresses": [
        {
            "street": "Neugasse 10",
            "city": "Zürich",
            "state": "ZH",
            "zip": "8005",
            "country": "Switzerland",
            "type": "work",
        }
    ],
    #"subscribed": true,
    "timezone": "W. Europe Standard Time",
    "socialNetworks": [
        {
            "address": "'https://twitter.com/bashar_2018'",
            "type": "Twitter",
        }
    ],
}
)
pp.pprint(profile)

Output

'addresses': [{'city': 'Zürich',
            'country': 'Switzerland',
                    'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
                    'id': 'OEFPUzJBeTdaWlVhU3FDR194dEk3NU8xTThxakZuQXV4aE9obHM3SVdKTTE1',
                    'state': 'ZH',
                    'street': 'Neugasse 10',
                    'type': 'Work',
                    'typeId': 'SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1',
                    'zip': '8005'}],

Add address to profile

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.profile_add_address({
"contactId": "TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1"},
{'street':"Langäcker 13",
 'zip_code':"5430",
 'city':"Wettingen",
 'country':"Switzerland"},
"Home"
)
pp.pprint(profile)

Output

{'addresses': [{'city': 'Wettingen',
            'country': 'Switzerland',
            'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
            'id': 'eDZNV2d4Q1ZIR09UN2p1UlhzclVCdTM0LU81UW5TZzZmU05vLUtuVzdoMDE1',
            'state': '',
            'street': 'Langäcker 13',
            'type': 'Home',
            'typeId': 'M1ZkLXI3UnJqUWxUVDNFZUZ3MW5MdG5KSGZuN0lVemNDcXNLdzgzbjBDVTE1',
            'zip': '5430'},


           {'city': 'Zürich',
            'country': 'Switzerland',
            'countryId': 'QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1',
            'id': 'OEFPUzJBeTdaWlVhU3FDR194dEk3NU8xTThxakZuQXV4aE9obHM3SVdKTTE1',
            'state': 'ZH',
            'street': 'Neugasse 10',
            'type': 'Work',
            'typeId': 'SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1',
            'zip': '8005'}

Profile contains

  from hatchbuck import Hatchbuck
  import pprint
  pp = pprint.PrettyPrinter()
  hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
  profile = hatchbuck.profile_contains({
  "contactId": "QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1",
  "firstName": "Hawar",
  "lastName": "Afrin",
  "title": "Hawar1",
  "company": "HAWAR",
  "emails": [
    {
      "address": "bashar.said.2018@gmail.com",
      "type": "work",
    }
  ],
  "addresses": [
          {
              "street": "Neugasse 10",
              "city": "Zürich",
              "state": "ZH",
              "zip": "8005",
              "country": "Switzerland",
              "type": "work",
          }
      ],
  "phones": [
          {
              "number": "0041 76 803 77 34",
              "type": "work",
          }
      ]


}, "phones", "number", "0041 76 803 77 34")

  pp.pprint(profile)

Output

2018-03-13 09:21:23,556 - root - DEBUG - loading config file: aarno.yaml
2018-03-13 09:21:23,559 - root - DEBUG - loaded config: {'app_key': ' ', 'app_secret': ' ',
'hatchbuck_key': ' ', 'hatchbuck_source_xing': ' ', 'hatchbuck_source_linkedin': ' ',
'hatchbuck_source_carddav': ' ', 'hatchbuck_tag_xing': 'Xing-aarno', 'hatchbuck_tag_linkedin': 'LinkedIn-aarno',
'hatchbuck_tag_carddav': 'Adressbuch-aarno', 'user_key': ' ', 'user_secret': ' ', 'carddav_path':         'carddav/360afdfd542ea44f/'}

True

Add a profile

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.profile_add("emails", "address", "baschar.said@hotmail.com", {'type': 'Home'})
pp.pprint(profile)

Output

{'addresses': [],
'campaigns': [],
'contactId': 'cFk2SXB1emNXWFFuRGRPWnNCeGsyRUZ1NmxCeVdFZlJkV3lzdWVKN0dpZzE1',
'customFields': [{'name': 'Comments', 'type': 'MText', 'value': ''},
                 {'name': 'Invoiced', 'type': 'Number', 'value': ''},
                 {'name': 'Language', 'type': 'Text', 'value': ''},
                 {'name': 'working at company since',
                  'type': 'Text',
                  'value': ''},
                 {'name': 'company size', 'type': 'Text', 'value': ''},
                 {'name': 'Birthday', 'type': 'Date', 'value': ''}],
'emails': [{'address': 'baschar.said@hotmail.com',
            'id': 'SVJhdUZDUjZNcllHYVRnZW5XWVZub1kzYmdIRTNkUmpwbUllYlJPNkxKazE1',
            'type': 'Work',
            'typeId': 'VmhlQU1pZVJSUFFJSjZfMHRmT1laUmwtT0FMNW9hbnBuZHd2Q1JTdE0tYzE1'}],
'firstName': '',
'instantMessaging': [],
'lastName': '',
'phones': [],
'referredBy': '',
'salesRep': {'id': 'VGpwQTRGTmw4MExVODl1b1BmXzBodTBwWnZXS2dUZzVvSkJKZUx4UlFpdzE1',
             'username': 'aarno.aukia'},
'socialNetworks': [],
'status': {'id': 'UHQ4aTZUTXh2aDROQ0w0Z2dOSDlGM2ZkaXFRelhTLTJEVHNKWU02TXJ1bzE1',
           'name': 'Customer Opportunity'},
'subscribed': True,
'tags': [],
'timezone': 'W. Europe Standard Time',
'website': []}

Add tags

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile =hatchbuck.add_tag('TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1', 'new tag')
pp.pprint(profile)

Output

2018-03-13 09:55:51,514 - root - DEBUG - starting with arguments: Namespace(config='aarno.yaml', noop=False,     verbose=True)
2018-03-13 09:55:51,514 - root - DEBUG - loading config file: aarno.yaml
2018-03-13 09:55:51,517 - root - DEBUG - loaded config: {'app_key': ' ', 'app_secret': ' ', 'hatchbuck_key': ' ',     'hatchbuck_source_xing': ' ',
'hatchbuck_source_linkedin': ' ', 'hatchbuck_source_carddav': ' ', 'hatchbuck_tag_xing': 'Xing-aarno',     'hatchbuck_tag_linkedin': 'LinkedIn-aarno',
'hatchbuck_tag_carddav': 'Adressbuch-aarno', 'user_key': ' ', 'user_secret': ' ', 'carddav_path': 'carddav/360afdfd542ea44f/'}

2018-03-13 09:55:51,517 - hatchbuck - DEBUG - adding tag new tag to contact     TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1
2018-03-13 09:55:51,533 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (1):     api.hatchbuck.com
2018-03-13 09:55:52,216 - requests.packages.urllib3.connectionpool - DEBUG - "POST     /api/v1/contact/TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1/Tags?api_key= '' HTTP/1.1" 201 14

2018-03-13 09:55:52,220 - hatchbuck - DEBUG - success: “Tag(s) added”

Notice: the addition of a tag when viewing the profile

'tags': [{'id': 'Y0Y4VFRhbDZSZFl2eENuYWU4M2s4Q3FsNjExTk5ldjdVOFdWU29ZRy1UTTE1',
       'name': 'new tag',
       'score': 1}],

Add birthday to profile

from hatchbuck import Hatchbuck
import pprint
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.profile_add_birthday({
"contactId": "TmpmT0QyUGE3UGdGejZMay1xbDNyUHJFWU91M2VwN0hCdGtZZFFCaWRZczE1"},
{'month': '1', 'day': '1', 'year': '1984'})
pp.pprint(profile)

Output

'customFields': [{'name': 'Comments', 'type': 'MText', 'value': ''},
             {'name': 'Invoiced', 'type': 'Number', 'value': ''},
             {'name': 'Language', 'type': 'Text', 'value': ''},
             {'name': 'working at company since',
               'type': 'Text',
               'value': ''},
             {'name': 'company size', 'type': 'Text', 'value': ''},
             {'name': 'Birthday', 'type': 'Date', 'value': '1/1/1984'}],

Countries lookup

Hatchbuck uses a not very intuitive countryId in postal addresses, the lookup table is at https://app.hatchbuck.com/Account/APICountryKey_Json and saved in hatchbuck_countries.json in this repo

Phone number cleanup

When combining data from multiple sources multiple phone numbers pile up in the contact that are actually the same number, just in different formats (national, international) and formatted differently (with spaces, brackets etc, without). The module includes a method to clean and deduplicate all phone numbers

from hatchbuck import Hatchbuck
pp = pprint.PrettyPrinter()
hatchbuck = Hatchbuck('NINIGkhjhg348gssdh2uh2hf6gsjd...')
profile = hatchbuck.search_email('bashar.said@vshn.ch')
# contains both "+41445455300" and "0445455300" phone numbers,
# being the same number in international and national formats
profile = hatchbuck.clean_all_phone_numbers(profile)
# the redundant local number is removed and the international number is formatted as "+41 44 545 53 00"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatchbuck-1.0.23.tar.gz (35.7 kB view details)

Uploaded Source

File details

Details for the file hatchbuck-1.0.23.tar.gz.

File metadata

  • Download URL: hatchbuck-1.0.23.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.5.6

File hashes

Hashes for hatchbuck-1.0.23.tar.gz
Algorithm Hash digest
SHA256 b1c43951b1ea1dbbfd7a337233f4b142adcb92f50ff1ae786cefbedfe002dee5
MD5 888c4b0c6b6aa2fae3927c28fabb5ff0
BLAKE2b-256 3d8cbb8302eba1bec82bdca63d03dc5b041e25713ec3a4b024a0ff2440e5e3e9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page