Skip to content

sudo-eugene/closeio-api

 
 

Repository files navigation

Close API

PyPI version CircleCI

A convenient Python wrapper for the Close API.

Installation

pip install closeio

Sample Usage (of API client)

from closeio_api import Client

api = Client('YOUR_API_KEY')

# post a lead
lead = api.post('lead', data={'name': 'New Lead'})

# get 5 most recently updated opportunities
opportunities = api.get('opportunity', params={'_order_by': '-date_updated', '_limit': 5})

# fetch multiple leads (using search syntax)
lead_results = api.get('lead', params={
    '_limit': 10,
    '_fields': 'id,display_name,status_label',
    'query': 'custom.my_custom_field:"some_value" status:"Potential" sort:updated'
})

Utility Scripts

Environment Synchronization

The repository includes a utility script fetch_custom_fields.py that helps synchronize various configurations between Close.io environments (e.g., production to development). This script can sync:

  • Custom fields (Lead, Contact, Opportunity, Activity)
  • Custom activity types
  • Lead statuses
  • Opportunity statuses

Usage:

# Set up environment variables in .env file
CLOSEIO_API_KEY_PROD=your_production_api_key
CLOSEIO_API_KEY_DEV=your_development_api_key

# Run the script
python sync_fields_to_dev.py

The script will:

  1. Fetch all configurations from the production environment
  2. Save the raw data to JSON files in the data/ directory
  3. Create missing items in the development environment
  4. Remove items from development that don't exist in production
  5. Generate detailed reports of all changes

Example scripts

Check out https://github.com/closeio/closeio-api-scripts for helpful scripts already written to accomplish some common tasks.

Other Languages

There are unofficial API clients available in other languages too, thanks to some awesome contributors:

About

Python API Client for Close

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%