Skip to main content

Async python wrapper for KeepinCRM API

Project description

Async Python Wrapper for KeepinCRM API

This is an async Python wrapper for the KeepinCRM API that allows you to interact with the API using simple and convenient methods. The wrapper provides a KeepinClient class with async methods for making HTTP requests and retrieving data from the API.

Installation

You can install the library using pip:

pip install aiokeepin

Usage

To use the KeepinCRM async Python wrapper, import the KeepinClient class from the library:

from aiokeepin import KeepinClient

Initializing the Client

Create an instance of the KeepinClient class by providing your API key:

client = KeepinClient(api_key='YOUR_API_KEY')

Making API Requests

The KeepinClient instance provides async methods that correspond to the different HTTP request methods (GET, POST, PATCH, PUT, DELETE). Each method returns a dictionary containing the response from the API.

GET Request Example

response = await client.get('/clients')
print(response)

POST Request Example

data = {
  "email": "pib@example.com",
  "company": "Назва чи ПІБ",
  "lead": True,
  "source_id": 5,
  "status_id": 1,
  "phones": [
    "+380000000001"
  ],
  "tag_names": [
    "VIP"
  ],
  "contacts_attributes": [
    {
      "fullname": "Прізвище Імʼя По батькові",
      "phones": [
        "+380000000002"
      ],
      "custom_fields": [
        {
          "name": "Посада",
          "value": "Директор"
        }
      ]
    }
  ]
}

response = await client.post('/clients', data=data)
print(response)

PATCH Request Example

data = {
  "email": "new_email@example.com"
}

response = await client.patch('/clients/{client_id}', data=data)
print(response)

PUT Request Example

data = {
  "email": "updated_email@example.com"
}

response = await client.put('/clients/{client_id}', data=data)
print(response)

DELETE Request Example

response = await client.delete('/clients/{client_id}')
print(response)

GET Paginated Items Example

response = await client.get_paginated_items('/clients')

Error Handling

In case of an error response from the API, an exception will be raised. You can handle exceptions using try-except blocks. Here's an example:

from aiokeepin.exceptions import KeepinStatusError

try:
    response = await client.get('/nonexistent_endpoint')
except KeepinStatusError as e:
    print(f"Error: {e}")

Documentation

For detailed information on the KeepinCRM API, refer to the official API documentation: KeepinCRM API Documentation

License

This project is licensed under the MIT License. See the LICENSE file for more information.

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

aiokeepin-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

aiokeepin-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiokeepin-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.11 Linux/6.2.15-300.fc38.x86_64

File hashes

Hashes for aiokeepin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac148e44833eb2e31acf556d7e378206054684b5195e7deeddc4a8a77197a391
MD5 ccfdc44a1e2f3ea1b898c052a704c94e
BLAKE2b-256 03b6f261f6afe23dd7fcf59caaa98f26a889f8d4f21fdaf27a31cff7a0050473

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: aiokeepin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.11 Linux/6.2.15-300.fc38.x86_64

File hashes

Hashes for aiokeepin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c4851b37cc4db37c0e112961efa3e3e0a75b1b3fa65f571c8f3e1e082fd7ced
MD5 df316298e0241f534fbe7e15a90e5ce4
BLAKE2b-256 7674e1cd507a4476e357b674c8481d7fbd200a90fbdc4a465e36d00c153864fe

See more details on using hashes here.

Provenance

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