Skip to main content

A simple library to interact with Salesforce REST API using OAuth 2.0 Client Credentials Flow.

Project description

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

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.

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 for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

salesforcerestapi-0.1.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salesforcerestapi-0.1.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file salesforcerestapi-0.1.4.tar.gz.

File metadata

  • Download URL: salesforcerestapi-0.1.4.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for salesforcerestapi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 424e459bcfa65426066f616115807347773c4908735bcbb7e5a71f2ef8318b7b
MD5 07f6fda1a89ae98bff22bd3fca25d00e
BLAKE2b-256 3da13e21016e70b1c547e60c740d581666334f3251beab77590df87028cf2c4b

See more details on using hashes here.

File details

Details for the file salesforcerestapi-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for salesforcerestapi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8c6daba2f0374ee071eea7eae089abc37572448b82c736e87a4e96162cfd3d9e
MD5 c263121cc2c60711a0dacac93ac3ec91
BLAKE2b-256 42e0212de17b3d1cf487da5d48c0156f19a36853ea805ed019a00b41cd756a90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page