Skip to main content

Python wrapper on Nutshell CRM JSON RPC API

Project description

Nushell API

This is a work-in-progress attempt at a pythonic API for Nutshell.

Installation

pip install nutshell

Nutshell access credentials should be stored in a .env file in the root directory or as environment variables. The following variables are required:

NUTSHELL_KEY=your_api_key
NUTSHELL_USERNAME=your_username

Usage

Pydantic dataclasses for supported API methods are available in the methods module.

import asyncio

from rich import print

from nutshell.methods import FindActivityTypes
from nutshell.nutshell_api import NutshellAPI

single_call = FindActivityTypes()

nut = NutshellAPI(single_call)
call_response = asyncio.run(nut.call_api())

for call in call_response:
    print(call)

Results are returned as a list of tuples. The first element is the method instance, the second is the response.

(
    FindActivityTypes(
        api_method='findActivityTypes',
        order_by='name',
        order_direction='ASC',
        limit=50,
        page=1,
        params={
            'orderBy': 'name',
            'orderDirection': 'ASC',
            'limit': 50,
            'page': 1
        }
    ),
    FindActivityTypesResult(
        result=[
            ActivityTypes(
                stub=True,
                id=1,
                rev='1',
                entity_type='Activity_Types',
                name='Phone Call / Meeting'
            ),
            ActivityTypes(
                stub=True,
                id=3,
                rev='3',
                entity_type='Activity_Types',
                name='Email/Log'
            ),
        ]
    )
)

All responses have a result attribute that contains the data returned by the API. The data is returned as a list of Pydantic models based on the API method invoked.

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

nutshell-0.2.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

nutshell-0.2.2-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

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