# SalesforceRESTAPI
A simple Python library to interact with the Salesforce REST API using OAuth 2.0 Client Credentials Flow.
## Features
- Authenticate with Salesforce using OAuth 2.0 Client Credentials
- Basic CRUD operations (create, read, update, delete) for Salesforce objects
- SOQL query support
- Apex script execution via Tooling API
- Record verification utilities
## Installation
```bash
pip install SalesforceRESTAPI
```
## Usage
> **Note:** As of version 0.1.3, authentication state (`instance_url`, `access_token`, `headers`) is stored as class variables. You must call `SalesforceRESTAPI.authenticate(...)` before using any instance methods. All instances share the same authentication state.
```python
from SalesforceRESTAPI import SalesforceRESTAPI
# Authenticate (call this once before using any instance methods)
SalesforceRESTAPI.authenticate(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', login_url='https://login.salesforce.com')
# Now you can use instance methods
sf = SalesforceRESTAPI()
# Create a record
account_id = sf.create_record('Account', Name='Test Account', Industry='Technology')
# Get a record
account = sf.get_record('Account', account_id)
# Update a record
sf.update_record('Account', account_id, Name='Updated Name')
# Delete a record
sf.delete_record('Account', account_id)
# Run a SOQL query
results = sf.queryRecords('SELECT Id, Name FROM Account')
# Execute anonymous Apex
apex_result = sf.execute_apex('System.debug("Hello World");')
# Revoke authentication (clears class-level state)
sf.revoke()
```
## Requirements
- Python 3.6+
- requests
- python-dotenv (for loading .env files in tests)
## License
MIT License. See [LICENSE](LICENSE) for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/arcsona/SalesforceRESTAPI",
"name": "SalesforceRESTAPI",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Pedro Bazan",
"author_email": "pedro.bazan@arcsona.com",
"download_url": "https://files.pythonhosted.org/packages/83/63/3fbaab977f319a00255fb87caea3cdf3add358d71c8cdaeb2d4f6f42d02a/salesforcerestapi-0.1.9.tar.gz",
"platform": null,
"description": "# SalesforceRESTAPI\n\nA simple Python library to interact with the Salesforce REST API using OAuth 2.0 Client Credentials Flow.\n\n## Features\n- Authenticate with Salesforce using OAuth 2.0 Client Credentials\n- Basic CRUD operations (create, read, update, delete) for Salesforce objects\n- SOQL query support\n- Apex script execution via Tooling API\n- Record verification utilities\n\n## Installation\n\n```bash\npip install SalesforceRESTAPI\n```\n\n## Usage\n\n> **Note:** As of version 0.1.3, authentication state (`instance_url`, `access_token`, `headers`) is stored as class variables. You must call `SalesforceRESTAPI.authenticate(...)` before using any instance methods. All instances share the same authentication state.\n\n```python\nfrom SalesforceRESTAPI import SalesforceRESTAPI\n\n# Authenticate (call this once before using any instance methods)\nSalesforceRESTAPI.authenticate(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', login_url='https://login.salesforce.com')\n\n# Now you can use instance methods\nsf = SalesforceRESTAPI()\n\n# Create a record\naccount_id = sf.create_record('Account', Name='Test Account', Industry='Technology')\n\n# Get a record\naccount = sf.get_record('Account', account_id)\n\n# Update a record\nsf.update_record('Account', account_id, Name='Updated Name')\n\n# Delete a record\nsf.delete_record('Account', account_id)\n\n# Run a SOQL query\nresults = sf.queryRecords('SELECT Id, Name FROM Account')\n\n# Execute anonymous Apex\napex_result = sf.execute_apex('System.debug(\"Hello World\");')\n\n# Revoke authentication (clears class-level state)\nsf.revoke()\n```\n\n## Requirements\n- Python 3.6+\n- requests\n- python-dotenv (for loading .env files in tests)\n\n## License\nMIT License. See [LICENSE](LICENSE) for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple library to interact with Salesforce REST API using OAuth 2.0 Client Credentials Flow.",
"version": "0.1.9",
"project_urls": {
"Homepage": "https://github.com/arcsona/SalesforceRESTAPI"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "541b749f20024a4b49e652727dfd132b525ebede6fa4d53f84939e5668275386",
"md5": "e7770052e26e1f64b97d584671f736de",
"sha256": "db4acf6a0ad07e609b20860a309c3ab838f8b87f4cf404e28085df0150fbde5b"
},
"downloads": -1,
"filename": "salesforcerestapi-0.1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e7770052e26e1f64b97d584671f736de",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5517,
"upload_time": "2025-07-31T02:40:52",
"upload_time_iso_8601": "2025-07-31T02:40:52.470821Z",
"url": "https://files.pythonhosted.org/packages/54/1b/749f20024a4b49e652727dfd132b525ebede6fa4d53f84939e5668275386/salesforcerestapi-0.1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "83633fbaab977f319a00255fb87caea3cdf3add358d71c8cdaeb2d4f6f42d02a",
"md5": "d7eee9da8ccc132b9c8862939f12b962",
"sha256": "6ce52ccbad665e934a4c48325bed5eb4c8488e8011b44c09969d2efd7ed37905"
},
"downloads": -1,
"filename": "salesforcerestapi-0.1.9.tar.gz",
"has_sig": false,
"md5_digest": "d7eee9da8ccc132b9c8862939f12b962",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5706,
"upload_time": "2025-07-31T02:40:53",
"upload_time_iso_8601": "2025-07-31T02:40:53.662459Z",
"url": "https://files.pythonhosted.org/packages/83/63/3fbaab977f319a00255fb87caea3cdf3add358d71c8cdaeb2d4f6f42d02a/salesforcerestapi-0.1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 02:40:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "arcsona",
"github_project": "SalesforceRESTAPI",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "salesforcerestapi"
}