busbar-sf-api
A comprehensive Salesforce API client library for Rust, providing type-safe access to Salesforce APIs with built-in authentication, retry logic, and error handling.
This repository is undergoing rapid development and is not yet stable for production use. We're refactoring these API's out of other projects as reusable crates after realizing there is shockingly little coverage of Salesforce APIs in Rust, yet. More to come on that front. For now, if you're interested in providing feedback or even collaborating, let us know in [Discussions](https://github.com/composable-delivery/busbar-sf-apii>.
Features
- Authentication - OAuth 2.0 flows, JWT Bearer, and credentials management
- REST API - CRUD operations, queries, composite requests, and collections
- QueryBuilder - Fluent API with automatic SOQL injection prevention (secure by default)
- Bulk API 2.0 - Large-scale data operations with efficient processing
- Tooling API - Apex operations, debug logs, and code coverage
- Metadata API - Deploy and retrieve Salesforce metadata
- Async/Await - Built on Tokio for high-performance async operations
- Retry Logic - Automatic retries with exponential backoff
- Security - Sensitive data redaction in debug output and logging
- Tracing - Built-in tracing support for observability
Crates
This workspace includes the following crates:
- busbar-sf-client - Core HTTP client infrastructure with retry, compression, and rate limiting
- busbar-sf-auth - Authentication: OAuth 2.0 flows, JWT Bearer, credentials management
- busbar-sf-rest - REST API: CRUD, Query, Describe, Composite, Collections
- busbar-sf-tooling - Tooling API: Apex operations, debug logs, code coverage
- busbar-sf-bulk - Bulk API 2.0: Large-scale data operations
- busbar-sf-metadata - Metadata API: Deploy and retrieve metadata
Installation
Add this to your Cargo.toml:
[]
= "0.0.2"
= { = "1.40", = ["full"] }
= { = "1.0", = ["derive"] }
= "1.0"
Or install individual crates as needed:
[]
= "0.0.2"
= "0.0.2"
Quick Start
Safe Query Builder (Recommended)
The QueryBuilder provides a fluent API with automatic SOQL injection prevention:
use SalesforceCredentials;
use ;
use Deserialize;
async
Using Credentials from Salesforce CLI
use SalesforceCredentials;
use SalesforceRestClient;
async
OAuth 2.0 Authentication
use ;
use env;
async
Bulk API Operations
use ;
use ;
async
Metadata API
use MetadataClient;
async
Examples
See the examples directory for comprehensive examples:
- basic_auth.rs - Authentication methods (OAuth, JWT, SFDX, environment variables)
- rest_crud.rs - REST API CRUD operations
- queries.rs - SOQL queries with security best practices
- error_handling.rs - Error handling patterns and retry logic
- bulk_operations.rs - Bulk API 2.0 insert, update, and query operations
Run any example with:
Security
This library is designed with security in mind. See SECURITY.md for full details.
Key Security Features:
- ✅ QueryBuilder - Fluent API with automatic SOQL injection prevention (RECOMMENDED)
- ✅ Automatic credential redaction in logs and debug output
- ✅ SOQL injection prevention utilities (escape_string, field validation)
- ✅ URL parameter encoding to prevent path traversal
- ✅ Secure token storage with restrictive file permissions
- ✅ Input validation for IDs, field names, and SObject names
Security Best Practices:
use QueryBuilder;
// RECOMMENDED - QueryBuilder is safe by default
let accounts: = new?
.select
.where_eq? // Automatically escaped!
.execute
.await?;
// Alternative - Manual escaping (easy to forget!)
use soql;
let safe_name = escape_string;
let query = format!;
For security vulnerabilities, see our Security Policy
Requirements
- Rust 1.88 or later
- Tokio runtime for async operations
Documentation
- 📖 API Documentation - Complete API reference
- 🔒 Security Policy - Security best practices and vulnerability reporting
- 🧪 Integration Testing Guide - How to run integration tests
- 📋 Code Review - Comprehensive code review for v0.0.2 release
- 📝 Changelog - Version history and release notes
- 🤝 Contributing Guidelines - How to contribute
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development
# Clone the repository
# Build all crates
# Run tests
# Run integration tests (requires SF_AUTH_URL or authenticated SF CLI)
# See INTEGRATION_TESTING.md for details
SF_AUTH_URL="force://..."
SF_AUTH_URL="force://..."
# Run linter
# Format code
Community
- 💬 GitHub Discussions - Ask questions, share ideas, and discuss the project
- 🐛 Issue Tracker - Report bugs and request features
- 📖 Documentation - API documentation
License
http://www.apache.org/licenses/LICENSE-2.0 Licensed under either of:http://opensource.org/licenses/MIT
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.