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

Usage

Create desired API calls as Pydantic models, pass the models to the NutshellAPI class, and call the API.

import asyncio
import os

from rich import print
from dotenv import load_dotenv
import nutshell as ns

load_dotenv()

single_call = ns.FindActivityTypes()

nut = ns.NutshellAPI(os.getenv("NUTSHELL_USERNAME"), password=os.getenv("NUTSHELL_KEY"))
nut.api_calls = [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 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.3.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

nutshell-0.2.3-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