{"id":9290,"library":"salesforce-api","title":"Salesforce API Wrapper","description":"The `salesforce-api` library (felixlindstrom/python-salesforce-api) provides an easy-to-use, flexible, and testable solution for communicating with Salesforce through its REST and SOAP APIs. It handles authentication, record management (CRUD), SOQL queries, and bulk operations. The library is currently at version 0.1.46 and is actively maintained with contributions as recent as 2024.","status":"active","version":"0.1.46","language":"en","source_language":"en","source_url":"https://github.com/felixlindstrom/python-salesforce-api","tags":["salesforce","crm","api","rest","soap"],"install":[{"cmd":"pip install salesforce-api","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"HTTP client for making API calls.","package":"requests"},{"reason":"XML parsing for SOAP API interactions.","package":"xmltodict"},{"reason":"Date and time parsing/formatting for API requests.","package":"iso8601"}],"imports":[{"symbol":"Salesforce","correct":"from salesforce_api import Salesforce"},{"note":"This library (`salesforce-api` by felixlindstrom) is distinct from `simple-salesforce`, a different popular Salesforce Python client. Ensure you import from the correct package.","wrong":"from simple_salesforce import Salesforce","symbol":"Salesforce","correct":"from salesforce_api import Salesforce"}],"quickstart":{"code":"import os\nfrom salesforce_api import Salesforce\n\n# It's recommended to use environment variables for sensitive credentials.\nSF_USERNAME = os.environ.get('SF_USERNAME', 'your_username@example.com')\nSF_PASSWORD = os.environ.get('SF_PASSWORD', 'your_password')\nSF_SECURITY_TOKEN = os.environ.get('SF_SECURITY_TOKEN', 'your_security_token')\n\n# For sandbox environments, you might need to specify the domain.\n# For example, domain='test'\n\ntry:\n    client = Salesforce(\n        username=SF_USERNAME,\n        password=SF_PASSWORD,\n        security_token=SF_SECURITY_TOKEN\n    )\n    print(\"Successfully connected to Salesforce!\")\n\n    # Example: Query an SObject\n    # Note: Replace 'Account' and field names with actual objects/fields in your org.\n    accounts = client.query(\"SELECT Id, Name FROM Account LIMIT 5\")\n    print(\"First 5 Accounts:\")\n    for record in accounts['records']:\n        print(f\"  ID: {record['Id']}, Name: {record['Name']}\")\n\n    # Example: Create a new contact (adjust fields as per your Salesforce org)\n    # new_contact_data = {\n    #     'LastName': 'TestContact',\n    #     'Email': 'test@example.com'\n    # }\n    # result = client.Contact.create(new_contact_data)\n    # print(f\"Created Contact ID: {result['id']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to establish a connection to Salesforce using username, password, and security token authentication. It then performs a simple SOQL query to retrieve account records. Always use environment variables or a secure configuration management system for credentials in production. You may need to create a Connected App in Salesforce and use OAuth for more robust authentication flows."},"warnings":[{"fix":"Implement error handling with exponential backoff for retries. Monitor API usage in Salesforce 'System Overview' to anticipate limits.","message":"Salesforce API calls are subject to daily and hourly limits. Exceeding these limits can lead to `TOO_MANY_REQUESTS` (429 HTTP status) or other errors, temporarily blocking API access.","severity":"gotcha","affected_versions":"All"},{"fix":"In Salesforce Setup, navigate to 'App Manager' -> 'Connected Apps', then 'Manage' -> 'Edit Policies'. Ensure 'IP Relaxation' is set to 'Relax IP restrictions' or that your application's IP is whitelisted under 'Network Access'.","message":"Authentication with username, password, and security token may require relaxing IP restrictions in Salesforce or whitelisting client IP addresses if operating from a new location.","severity":"gotcha","affected_versions":"All"},{"fix":"Initialize the `Salesforce` client with `client = Salesforce(..., domain='test')` for sandbox environments.","message":"The default login URL is for production. For sandbox environments, you must explicitly specify `domain='test'` or the full sandbox login URL during client initialization.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Adjust your data to avoid duplicates, or configure Salesforce Duplicate Rules to exclude the integration user or specific scenarios.","cause":"Salesforce org has active duplicate rules or matching rules that prevent the creation or update of records that match existing ones.","error":"statusCode='DUPLICATES_DETECTED', message='You're creating a duplicate record.'"},{"fix":"Ensure that picklist values provided in your code exactly match the values configured in Salesforce. If the picklist is restricted, only defined values are allowed. Consider making picklists non-restricted if appropriate for your integration.","cause":"Attempting to insert or update a picklist field with a value that is not defined in Salesforce's picklist options, or the picklist is restricted.","error":"statusCode='INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST'"},{"fix":"Verify that your username, password, and security token are correct and up-to-date. If using OAuth, ensure the refresh token mechanism is correctly implemented to obtain new access tokens.","cause":"The authentication token used for API calls is either not provided, has become invalid (e.g., password change), or has expired.","error":"The access token in the request is missing, invalid, or expired."},{"fix":"Implement retry logic with a delay (e.g., exponential backoff) for operations that may encounter this error. Design integrations to minimize concurrent updates to the same records where possible.","cause":"Multiple processes or API calls are attempting to update the same Salesforce record simultaneously, leading to a database locking conflict.","error":"UNABLE_TO_LOCK_ROW"}]}