Salesforce REST API client
Project description
aiosalesforce
Python client for the Salesforce REST API
About
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
aiosalesforce
is a modern, production-ready Python client for the Salesforce REST API.
It is built on top of the httpx
library and provides a simple and intuitive API
for interacting with Salesforce's REST API.
- Fast: designed from the ground up to be fully asynchronous
- Fully typed: every part of the library is fully typed and annotated
- Intuitive: API follows naming conventions of the Salesforce REST API while staying idiomatic to Python
- Reliable: flexible and robust retrying configuration
- 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
- Track your API usage: built-in support for tracking Salesforce API usage
Requirements
aiosalesforce
depends on:
- Python 3.11+
- httpx
Installation
pip install aiosalesforce
Quickstart
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiosalesforce-0.1.0.tar.gz
(12.2 kB
view hashes)
Built Distribution
Close
Hashes for aiosalesforce-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 903aa24e9a3e2ffc14e42759f94b70433c2ab93b0908bfdfa117a159b2eb52b4 |
|
MD5 | 92ba0dbd800f03279aea618c8466e190 |
|
BLAKE2b-256 | 99b43acc9d94d71f3cc69cdb5fc03205f46f8444b8c331a425c4fb1cb344428a |