{"id":805,"library":"simple-salesforce","title":"Simple-Salesforce","description":"Simple-Salesforce is a basic Salesforce.com REST API client built for Python 3.9 and newer versions. It provides a low-level interface to the Salesforce REST Resource and APEX API, returning JSON responses as Python dictionaries. The library facilitates common operations like authentication, CRUD operations on Salesforce objects, SOQL/SOSL queries, and interaction with Bulk and Metadata APIs. It's actively maintained with regular bug fixes and feature enhancements.","status":"active","version":"1.12.9","language":"python","source_language":"en","source_url":"https://github.com/simple-salesforce/simple-salesforce.git","tags":["salesforce","api client","crm","rest api","cloud"],"install":[{"cmd":"pip install simple-salesforce","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for all HTTP communication with the Salesforce API.","package":"requests","optional":false},{"reason":"Commonly used in quickstart examples for managing credentials securely via environment variables.","package":"python-dotenv","optional":true}],"imports":[{"note":"The primary class for interacting with the Salesforce API.","symbol":"Salesforce","correct":"from simple_salesforce import Salesforce"},{"note":"A helper function for more granular control over the login process, though 'Salesforce' constructor handles most cases.","symbol":"SalesforceLogin","correct":"from simple_salesforce.api import SalesforceLogin"}],"quickstart":{"code":"import os\nfrom simple_salesforce import Salesforce\n\n# It's highly recommended to use environment variables for credentials\nUSERNAME = os.environ.get('SF_USERNAME', 'your_username@example.com')\nPASSWORD = os.environ.get('SF_PASSWORD', 'your_password')\nSECURITY_TOKEN = os.environ.get('SF_SECURITY_TOKEN', 'your_security_token')\n\n# Optional: for sandbox use domain='test'\n# For specific API versions, use sf_version='X.Y'\n\ntry:\n    sf = Salesforce(\n        username=USERNAME,\n        password=PASSWORD,\n        security_token=SECURITY_TOKEN,\n        # domain='test' # Uncomment for sandbox\n        # sf_version='59.0' # Uncomment for a specific API version\n    )\n    print(f\"Successfully connected to Salesforce instance: {sf.instance_url}\")\n\n    # Example: Query Account records\n    query_result = sf.query(\"SELECT Id, Name FROM Account LIMIT 5\")\n    print(\"\\nFirst 5 Account Names:\")\n    for record in query_result['records']:\n        print(f\"  - {record['Name']} (Id: {record['Id']})\")\n\n    # Example: Create a new Account (replace with unique name for testing)\n    new_account_name = \"Test Account from simple-salesforce_\" + str(os.urandom(4).hex())\n    new_account = {'Name': new_account_name}\n    create_result = sf.Account.create(new_account)\n    print(f\"\\nCreated Account: {new_account_name} with Id: {create_result['id']}\")\n\n    # Example: Delete the created Account (cleanup)\n    delete_result = sf.Account.delete(create_result['id'])\n    print(f\"Deleted Account with Id: {create_result['id']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your SF_USERNAME, SF_PASSWORD, and SF_SECURITY_TOKEN environment variables are set correctly.\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Salesforce using username, password, and security token, then perform a simple SOQL query, create an account, and delete it. It emphasizes using environment variables for sensitive credentials."},"warnings":[{"fix":"Explicitly specify the desired API version in the `Salesforce` constructor using `sf_version='X.Y'` (e.g., `sf_version='41.0'`). Ensure your project runs on Python 3.9+ for compatibility.","message":"Breaking Change in v1.0.0: The default Salesforce API Version was increased to 42.0. This might affect queries or object interactions if your Salesforce instance expects an older API version. Additionally, support for Python 2.6, 2.7, 3.3, and 3.4 was removed.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Obtain your Salesforce security token (often by resetting your password in Salesforce settings) and provide it either concatenated with your password or as the `security_token` parameter to the `Salesforce` constructor.","message":"Security Token Confusion: When authenticating with username and password, a 'security token' is often required, especially from untrusted IP ranges. This token is usually emailed to you after a password reset and must be appended to the password or passed as a separate `security_token` argument.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully review your data payload against the Salesforce object's schema, ensuring all fields exist, have correct data types, and required fields are present. Validate external IDs for upsert operations.","message":"Bulk API 'InvalidBatch' Errors: When using the Bulk API (including Bulk 2.0), 'InvalidBatch' errors often indicate a schema mismatch, incorrect data types, or misrepresented fields in your payload. Error messages can be cryptic.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When initializing `Salesforce`, include `domain='test'` for sandbox environments (e.g., `sf = Salesforce(username=..., password=..., security_token=..., domain='test')`).","message":"Connecting to a Salesforce Sandbox: To connect to a sandbox instance, you must explicitly specify `domain='test'` in the `Salesforce` constructor, in addition to your credentials.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T19:36:01.107Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Ensure the library is installed using `pip install simple-salesforce` and imported as `from simple_salesforce import Salesforce`.","cause":"This error occurs when the 'simple-salesforce' library is not installed, or the import statement uses an incorrect module name (e.g., 'salesforce' instead of 'simple_salesforce').","error":"ModuleNotFoundError: No module named 'simple_salesforce'"},{"fix":"Verify all credentials are correct, ensure the security token is appended directly to the password if required, and check for any IP restrictions or login hour policies on the Salesforce side.","cause":"This error means the provided Salesforce username, password, or security token is incorrect, or IP restrictions are preventing access.","error":"SalesforceAuthenticationFailed: invalid_grant: authentication failure"},{"fix":"Double-check the API name of the object/field/record ID for typos, and ensure the authenticated user has appropriate read/write permissions for that resource in Salesforce.","cause":"This indicates that the Salesforce object, field, or record you are trying to access or manipulate does not exist, or your user profile lacks permissions to see it.","error":"SalesforceError: [StatusCode: 404] NOT_FOUND"},{"fix":"Re-establish the Salesforce connection by re-instantiating the `Salesforce` object with your credentials to generate a fresh, valid session ID.","cause":"The current Salesforce session has expired due to inactivity or invalidation, requiring re-authentication to obtain a new valid session.","error":"SalesforceError: [StatusCode: 500] INVALID_SESSION_ID: Session ID not found, please login again."},{"fix":"Correct the method or object name to match `simple-salesforce`'s conventions or Salesforce's API names (e.g., `sf.query_all()` for queries or `sf.Contact.get()` for object methods).","cause":"This error typically means you've misspelled a method name or an object's API name, or are attempting to access a non-existent attribute of the `Salesforce` connection object.","error":"AttributeError: 'Salesforce' object has no attribute 'query_all'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.12.9","cli_name":"","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.98,"mem_mb":17.4,"disk_size":"57.6M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.95,"mem_mb":17.2,"disk_size":"56.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":4.5,"import_time_s":0.68,"mem_mb":17.4,"disk_size":"58M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.7,"mem_mb":17.2,"disk_size":"57M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":1.13,"mem_mb":18.9,"disk_size":"60.8M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.26,"mem_mb":18.8,"disk_size":"59.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":4.3,"import_time_s":0.98,"mem_mb":18.9,"disk_size":"61M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.95,"mem_mb":18.8,"disk_size":"60M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":1.03,"mem_mb":18.7,"disk_size":"52.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.09,"mem_mb":18.6,"disk_size":"51.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.7,"import_time_s":1.07,"mem_mb":18.7,"disk_size":"53M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.07,"mem_mb":18.6,"disk_size":"52M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":19.6,"disk_size":"52.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.04,"mem_mb":19.5,"disk_size":"51.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.7,"import_time_s":0.96,"mem_mb":19.6,"disk_size":"53M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.06,"mem_mb":19.5,"disk_size":"51M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.8,"mem_mb":17,"disk_size":"57.6M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.86,"mem_mb":17,"disk_size":"56.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":5.2,"import_time_s":0.76,"mem_mb":17,"disk_size":"58M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.72,"mem_mb":17,"disk_size":"57M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}