PyCrunchbase supports all of these through a very simple interface.
Installation
Use the package manager pip to install PyCrunchbase.
pip install py-crunchbase-api
Usage
from py_crunchbase import PyCrunchbase
# API key can be set as the env variable PY_CRUNCHBASE_API_KEY
pycb = PyCrunchbase()
# OR passed as an argument
pycb = PyCrunchbase('api_key')
# If both are provided, the latter will take preference
from py_crunchbase import PyCrunchbase
pycb = PyCrunchbase()
api = pycb.search_organizations_api()
api.select(
'identifier', 'categories', 'location_identifiers', 'short_description', 'rank_org'
).where(
num_employees_enum__includes=['c_00101_00250'],
categories__includes=['58842728-7ab9-5bd1-bb67-e8e55f6520a0']
).order_by(
'rank_org'
)
for page in api.iterate():
for company in page:
print(company.permalink)
from py_crunchbase import PyCrunchbase
pycb = PyCrunchbase()
api = pycb.autocomplete_api()
for entity in api.autocomplete('box').limit(15).execute():
print(entity.permalink, entity.uuid)
from py_crunchbase import PyCrunchbase, Collections
pycb = PyCrunchbase()
api = pycb.autocomplete_api()
for entity in api.autocomplete('mayfield').select_collections(Collections.Principals.investors).execute():
print(entity.permalink, entity.uuid)
from py_crunchbase import PyCrunchbase, Collections
pycb = PyCrunchbase()
api = pycb.autocomplete_api()
for entity in api.autocomplete('airbnb').select_collections(Collections.Organizations.companies).execute():
print(entity.permalink, entity.uuid)
from py_crunchbase import PyCrunchbase, Collections
pycb = PyCrunchbase()
api = pycb.autocomplete_api()
for entity in api.autocomplete('united').select_collections(
Collections.Locations.countries, Collections.Locations.cities
).limit(10).execute():
print(entity.permalink, entity.uuid)
Deleted Entities API
from py_crunchbase import PyCrunchbase, Collections
pycb = PyCrunchbase()
api = pycb.deleted_entities_api()
for page in api.select_collections(
Collections.Organizations, Collections.People, Collections.FundingRounds, Collections.Events
).order_by_deleted_at().iterate():
for entity in page:
print(entity.uuid, entity.deleted_at)
Each Crunchbase Entity has its own class and can be accessed through Entities
from py_crunchbase import Entities
Organization = Entities.Organization
Person = Entities.Person
Entity classes can be extended through a decorator
from py_crunchbase import Entities
from py_crunchbase.decorators import override_entity
@override_entity(Entities.Organization)
class CustomOrganization(Entities.Organization):
pass
# now Entities.Organization will return CustomOrganization
Cards
Each Entity class defines its own cards (if any) and can be accessed through Cards
from py_crunchbase import Cards
OrgCards = Cards.Organization
print(OrgCards.investors)
print(OrgCards.founders)
# all available Org cards
print(OrgCards.all())
Collections
Collections are also defined in Entity class and can be accessed through Collections
from py_crunchbase import Collections
OrgCol = Collections.Organizations
print(OrgCol.companies)
print(OrgCol.schools)
Exception Handling
There are two ways to catch exceptions
from py_crunchbase import PyCrunchbase, CrunchbaseAPIException
pycb = PyCrunchbase()
api = pycb.autocomplete_api()
try:
entities = api.autocomplete('box').limit(15).execute()
except api.Exception:
pass
# OR through CrunchbaseAPIException
try:
entities = api.autocomplete('box').limit(15).execute()
except CrunchbaseAPIException:
pass
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.