Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aiosalesforce

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiosalesforce

Salesforce REST API client

  • 0.6.2
  • PyPI
  • Socket score

Maintainers
1

⚡ 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:

APIStatusDescription
SOQL QueryExecute SOQL queries
sObjectCRUD operations on Salesforce objects
Composite BatchExecute multiple independent subrequests
CompositeExecute 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.0Not planned (use Bulk API 2.0)
Bulk API 2.0Bulk 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())

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc