Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clearbit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os

from clearbit.company import Company
from clearbit.error import (ClearbitError, ParamsInvalidError)
from clearbit.resource import Resource
from clearbit.person import Person
from clearbit.company import Company
from clearbit.person_company import PersonCompany
from clearbit.resource import Resource
from clearbit.watchlist import Watchlist
from clearbit.watchlist import Entity as WatchlistEntity
from clearbit.watchlist import Individual as WatchlistIndividual

key = os.getenv('CLEARBIT_KEY', None)
6 changes: 6 additions & 0 deletions clearbit/examples/watchlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import clearbit

results = clearbit.WatchlistEntity.search(name='Ferland', fuzzy=True)

for result in results:
print(result)
32 changes: 32 additions & 0 deletions clearbit/watchlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from clearbit.resource import Resource

class Watchlist(Resource):
endpoint = 'https://watchlist.clearbit.com/v1'

@classmethod
def search(cls, **options):
if 'path' in options:
path = options['path']
del options['path']
else:
path = '/search/all'

options.setdefault('params', {})

for o in ['name', 'list', 'fuzzy']:
if o in options:
options['params'][o] = options[o]

response = cls.post(path, **options)

return(cls(item) for item in response.json())

class Individual(Watchlist):
@classmethod
def search(cls, **options):
return super(Individual, cls).search(path='/search/individuals', **options)

class Entity(Watchlist):
@classmethod
def search(cls, **options):
return super(Entity, cls).search(path='/search/entities', **options)