Skip to main content

SarvClient API Interaction Module

Overview

The SarvClient module provides a Python interface for interacting with the SarvCRM API. It simplifies authentication, CRUD operations, and module-specific functionalities for seamless integration with SarvCRM.

SarvCRM API Documents

Features

  • Authentication: Log in and manage sessions with the SarvCRM API.
  • CRUD Operations: Perform Create, Read, Update, and Delete transactions via simple methods.
  • Context Manager Support: Automatically handle login and logout within with statements.
  • Localization: Supports specifying the desired language for API interactions.
  • Utility Methods: Format dates, times, and other helper functionalities compliant with SarvCRM standards.
  • ENVMod Support: You can use the SarvClient with the ENVMod module for more rubost and flexible env management.

Installation

  1. Ensure you have Python 3.9+ installed.
  2. Make sure pip is installed
  3. Install the package
    pip install py-sarvcrm-api
    

Quick Start

CRUD

from sarvcrm_api import SarvClient

# Initialize the client
client = SarvClient(
    utype="your_utype",
    username="your_username",
    password="your_password",
    language="en_US",
    is_password_md5=True, # if your password is already md5
    #url=https://example.com/API.php  # if you use local server
    #frontend_url=https://example.com/  # if you use local server
)


# Use as a context manager for clean execution
with client:
    # Create new item in Accounts
    uid = client.Accounts.create(type='Corporate', name='RadinSystem', numbers=['02145885000'])
    print(f'New Account Created: {uid}')
    
    # Read one item record
    record = clinet.Accounts.read_record(uid)
    print(f'Single Account record: {record}')

    # Use query and selected_fields to read item
    opportunity = client.Opportunities.read_list(query="opportunities.id='<UID>'", selected_fields=['fullname'])
    print(f'Opportunity: {opportunity}')

    # Read List of items
    records = client.Accounts.read_list(order_by='accounts.name')
    print('Accounts list:')
    for account in Accounts:
        print(f' - {account}')

    # Update an item
    updated_item = client.Accounts.update(uid, name='Radin-System')
    print(f'Updated item id: {updated_item}')

    # Search for data by phone number
    result = client.search_by_number(number="02145885000", module=client.Accounts)  # module is optional
    print(f'Search by number result: {result}')

    # Delete Item
    deleted_item = client.Accounts.delete(uid)
    print(f'Deleted item: {deleted_item}')

Get me

This method on Users module will give the logged in user details.

my_user = client.Users.get_me()

Also you can use user_id property of client to get current users id

print(client.user_id)

Get current user items

Use read_user_created or read_user_assigned to get items created or assigned to the current user.

created_items = client.Leads.read_user_created(limit=10)
assigned_items = client.Tasks.read_user_assigned(limit=2)

Initiate client with ENVMod

You can load the client with environment variables using ENVMod class. This is useful for development and testing purposes.

from classmods import ENVMod
from sarvcrm_api import SarvClient

sarv_client = SarvClient(**ENVMod.load_args(SarvClient.__init__))

If you have environment variables set up, you can use them directly in your code. For example, read example file env example

Additional Features

  • Error Handling: This module raises requests.HTTPError and SarvException for API errors.
  • Secure Defaults: Passwords are hashed with MD5 unless explicitly provided as pre-hashed.
  • Easy Intraction: Added all modules and methods for easy intraction.

Developers

  • Contribute: Feel free to fork this repo and send pull request.

Testing

  • Pytest Support: create the .env file from .env_example and use pytest to start testing.
  • Test Cases: For now simple test methods are used and more test cases will be added soon.

License

This module is licensed for Radin System. For details, see the LICENSE file.

Metadata

Release files for py-sarvcrm-api 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-sarvcrm-api 1.4.1
File Size Uploaded
py_sarvcrm_api-1.4.1.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-sarvcrm-api 1.4.1
File Interpreter ABI Platform
py_sarvcrm_api-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / py_sarvcrm_api-1.4.1.tar.gz

Download URL py_sarvcrm_api-1.4.1.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
62f90e6cb8919bca75667c8dd03a084e61a70fbf4d1dd1b2c3958a95778cdb6f
BLAKE2b-256 checksum
How to use checksums
23b41274572757f0d3b247bcc406370ede1191ab1e5315110671c187801c8921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.

Transparency log

Release files / py_sarvcrm_api-1.4.1-py3-none-any.whl

Download URL py_sarvcrm_api-1.4.1-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c79429666f6c2f44661ca1f56f2560d32089dae7f3d760aac7a0cc2432806a0f
BLAKE2b-256 checksum
How to use checksums
6dee129ab3f08ab9460ab47d93695ed19c665b092d5c0af995f68cde31a4fab3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page