Skip to main content

Python SDK for the Neon CRM API v2

Project description

neoncrm

Python SDK for the Neon CRM API v2.

Installation

pip install .

Quick Start

from neoncrm import NeonCRM

neon = NeonCRM(org_id="YOUR_ORG_ID", api_key="YOUR_API_KEY")

# List accounts
accounts = neon.accounts.list(first_name="Jane")

# Get a single account
account = neon.accounts.get("12345")

# Create an individual account
result = neon.accounts.create({
    "individualAccount": {
        "primaryContact": {
            "firstName": "Jane",
            "lastName": "Doe",
            "email1": "jane@example.com",
        }
    }
})

# Search accounts
results = neon.accounts.search({
    "searchFields": [
        {"field": "Email", "operator": "EQUAL", "value": "jane@example.com"}
    ],
    "outputFields": ["Account ID", "First Name", "Last Name", "Email 1"],
    "pagination": {"currentPage": 0, "pageSize": 50},
})

Authentication

The SDK uses HTTP Basic authentication. You need:

  • Org ID — found in Settings > Organization Profile > Account Information
  • API Key — found in Settings > User Management > select user > enable API Access
# Production (default)
neon = NeonCRM(org_id="123", api_key="abc...")

# Trial instance
neon = NeonCRM(org_id="123", api_key="abc...", environment="trial")

# Custom base URL
neon = NeonCRM(org_id="123", api_key="abc...", base_url="https://custom.example.com/v2")

Resources

Resource Access Description
neon.accounts Accounts Individuals and companies
neon.activities Activities Activity tracking
neon.addresses Addresses Physical addresses
neon.campaigns Campaigns Fundraising campaigns
neon.custom_fields Custom Fields Custom fields and groups
neon.donations Donations Donation records
neon.events Events Event management
neon.event_registrations Event Registrations Registration management
neon.grants Grants Grant records
neon.memberships Memberships Membership management
neon.orders Orders Online store orders
neon.payments Payments Payment processing
neon.pledges Pledges Pledge management
neon.properties Properties System lookup values
neon.recurring_donations Recurring Donations Recurring giving
neon.store Online Store Products and catalogs
neon.webhooks Webhooks Webhook subscriptions
neon.volunteers Volunteers Volunteers, groups, opportunities, roles, shifts, time sheets
neon.households Households Household records

Common Patterns

CRUD Operations

Most resources follow a consistent pattern:

# Create
result = neon.donations.create({"accountId": "123", "amount": 50.00, ...})

# Read
donation = neon.donations.get("456")

# Update (full)
neon.donations.update("456", {... full object ...})

# Update (partial)
neon.donations.patch("456", {"amount": 75.00})

# Delete
neon.donations.delete("456")

Search

Resources with search support provide search(), search_fields(), and output_fields():

# Discover available search fields
fields = neon.donations.search_fields()

# Discover available output columns
columns = neon.donations.output_fields()

# Run a search
results = neon.donations.search({
    "searchFields": [
        {"field": "Donation Date", "operator": "GREATER_AND_EQUAL", "value": "2024-01-01"}
    ],
    "outputFields": ["Donation ID", "Amount", "Donor Name"],
    "pagination": {"currentPage": 0, "pageSize": 100},
})

Auto-Pagination

Use list_all() to iterate through all pages automatically:

for account in neon.accounts.list_all(last_name="Smith"):
    print(account["accountId"])

Events

# List upcoming events
events = neon.events.list(archived=False, start_date_after="2024-06-01T00:00:00Z")

# Get attendees
attendees = neon.events.attendees("789")

# Get event categories
categories = neon.events.categories()

Memberships

# Get membership levels and terms
levels = neon.memberships.levels()
terms = neon.memberships.terms()

# Create a membership
neon.memberships.create({...})

# Renew
neon.memberships.renew("456", {... renewal data ...})

Webhooks

# List existing webhooks
hooks = neon.webhooks.list()

# Create a webhook
neon.webhooks.create({
    "webhookName": "New Donation",
    "url": "https://example.com/hooks/donation",
    "eventTrigger": "createDonation",
})

System Properties

# Lookup values for forms
sources = neon.properties.sources()
funds = neon.properties.funds()
countries = neon.properties.countries()
genders = neon.properties.genders()

Error Handling

from neoncrm import (
    NeonCRMError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    ServerError,
)

try:
    neon.accounts.get("nonexistent")
except NotFoundError as e:
    print(f"Not found: {e}")
except AuthenticationError:
    print("Check your org_id and api_key")
except ValidationError as e:
    print(f"Bad request: {e.response_body}")
except ServerError:
    print("Neon CRM server error, try again later")
except NeonCRMError as e:
    print(f"API error {e.status_code}: {e}")

Context Manager

with NeonCRM(org_id="123", api_key="abc...") as neon:
    accounts = neon.accounts.list()

API Version

The SDK defaults to API version 2.11. Override if needed:

neon = NeonCRM(org_id="123", api_key="abc...", api_version="2.10")

Development

pip install -e ".[dev]"
pytest

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

neoncrm-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neoncrm-0.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file neoncrm-0.1.0.tar.gz.

File metadata

  • Download URL: neoncrm-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for neoncrm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f55dfd652000aac05927331c922df924c5bc3f7353934a60fdfed1250f0170f2
MD5 c28c6fed169b95214f45eec1fbbbe634
BLAKE2b-256 7628d900870df9a67faf739d8284d6b417acbaf0c793b9fdae02f6681615f3df

See more details on using hashes here.

File details

Details for the file neoncrm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: neoncrm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for neoncrm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37c018edb449f3713c9fe153953165524ad89bff1a56c4a43eca7abbc1ea2387
MD5 a331c9282416ae8ba9939940155a0885
BLAKE2b-256 11b633b5844f46a2b45675754920a021cb79ebb0600405487a293f53cfc46af1

See more details on using hashes here.

Supported by

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