Skip to main content

⚡ aiosalesforce ⚡

Asynchronous Python client for Salesforce APIs

Test Coverage PyPI Package

Documentation: https://georgebv.github.io/aiosalesforce

License: MIT

Support: ask a question or create an issue, any input is appreciated and would help develop the project

About

aiosalesforce is a modern, production-ready asynchronous Python client for Salesforce APIs. It is built on top of the httpx library and provides a simple and intuitive API for interacting with Salesforce's APIs (such as REST and Bulk).

  • Fast: designed from the ground up to be fully asynchronous :rocket:
  • Resilient: flexible and robust retrying configuration :gear:
  • Fully typed: every part of the library is fully typed and annotated :label:
  • Intuitive: API follows naming conventions of Salesforce's APIs while staying idiomatic to Python :snake:
  • Salesforce first: built with years of experience working with the Salesforce API it is configured to work out of the box and incorporates best practices and latest Salesforce API features :cloud:
  • Track your API usage: built-in support for tracking Salesforce API usage :chart_with_upwards_trend:

Supported APIs:

API Status Description
SOQL Query ✅ Execute SOQL queries
sObject ✅ CRUD operations on Salesforce objects
Composite Batch ✅ Execute multiple independent subrequests
Composite ✅ Execute multiple dependent subrequests
Composite Graph 🕒 Execute multiple composite graphs
sObject Tree 🕒 Create one or more sObject trees
sObject Collections 🕒 Execute multiple sObject operations
Bulk API 1.0 ❌ Not planned (use Bulk API 2.0)
Bulk API 2.0 ✅ Bulk ingest and query operations

Requirements

aiosalesforce depends on:

Optional dependencies:

Installation

pip install aiosalesforce

To use the JWT Bearer Flow authentication install with the jwt extra:

pip install aiosalesforce[jwt]

Demo

Example below shows how to:

  • Authenticate against Salesforce using the SOAP login method
  • Create a Salesforce client
  • Create a new Contact
  • Read a Contact by ID
  • Execute a SOQL query
import asyncio

from aiosalesforce import Salesforce
from aiosalesforce.auth import SoapLogin
from httpx import AsyncClient

# Reuse authentication session across multiple clients (refreshes automatically)
auth = SoapLogin(
    username="your-username",
    password="your-password",
    security_token="your-security-token",
)

async def main():
    async with AsyncClient() as client:
        # Create a Salesforce client
        salesforce = Salesforce(
            client,
            base_url="https://your-instance.my.salesforce.com",
            auth=auth,
        )

        # Create a new Contact
        contact_id = await salesforce.sobject.create(
            "Contact",
            {
                "FirstName": "John",
                "LastName": "Doe",
                "Email": "john.doe@example.com",
            },
        )
        print(f"Created Contact with ID: {contact_id}")

        # Read Contact by ID
        contact = await salesforce.sobject.get("Contact", contact_id)
        print(contact)

        # Execute a SOQL query
        async for record in salesforce.query("SELECT Id, Name FROM Contact"):
            print(record)


if __name__ == "__main__":
    asyncio.run(main())

Metadata

Release files for aiosalesforce 0.6.2

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

Source distribution (sdist)

Source distribution for aiosalesforce 0.6.2
File Size Uploaded
aiosalesforce-0.6.2.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiosalesforce 0.6.2
File Interpreter ABI Platform
aiosalesforce-0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 71.1 kB

Release files / aiosalesforce-0.6.2.tar.gz

Download URL aiosalesforce-0.6.2.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c8e039dc7b2bd535d231269690659eab6f2d4c2d9fc6dfa2ea92dce8e3fc25d3
BLAKE2b-256 checksum
How to use checksums
7d597b35b620dae5b70fd2893beedaca003005a3663948785dd6824cb3e1c8b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.3

Release files / aiosalesforce-0.6.2-py3-none-any.whl

Download URL aiosalesforce-0.6.2-py3-none-any.whl
Size 42.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a709e2048ae5d4353bb7d5ce4f928da9d82878c497bc460b1254c64adbde5c3
BLAKE2b-256 checksum
How to use checksums
cf29f50897b3e391126982207abfc7c359fccedd104257121756b324d137d7fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.6.2 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.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