Restforce

Restforce is the most popular Ruby gem for interacting with Salesforce using the Salesforce API, downloaded over 16,000,000 times.

Get started

1. Add restforce to your Gemfile, then run bundle install (or install it manually with gem install).

gem 'restforce', '~> 5.0.0'

The gem only supports Ruby 2.5 onwards. To use Restforce with earlier versions of Ruby, you'll need to use an earlier version of the gem.

2. Instantiate a Restforce client object with your API authentication details. You can use your username and password as below, or authenticate with OAuth.

# Don't commit your authentication details with your code - use environment variables <3
export SALESFORCE_USERNAME="username"
export SALESFORCE_PASSWORD="password"
export SALESFORCE_SECURITY_TOKEN="security token"
export SALESFORCE_CLIENT_ID="client id"
export SALESFORCE_CLIENT_SECRET="client secret"
export SALESFORCE_API_VERSION="38.0"
client = Restforce.new

3. Query Salesforce like a pro.

my_leads = client.query("SELECT Id, Source FROM Lead where OwnerId = 'INSERT_USER_ID_HERE'")
# => #<Restforce::Collection >

Learn more

To discover all the great things you can do with Restforce, check out the README and the full documentation.

Stay up to date

Get involved

We welcome contributions and bug reports so we can together make Restforce as great as possible 💕

We'd love to have you involved, whether it's your first open source contribution or your thousandth. To get started, see our CONTRIBUTING.md, and take note of our code of conduct.

If you have any questions, contact Tim Rogers, the maintainer.

Get in touch

Want help using Restforce, with contributing, or have another question?

Get in touch with Tim Rogers, the maintainer of Restforce, at tim@restforce.org.

Restforce is released under the MIT license
Page last updated 10th July 2020
© Tim Rogers and Eric J. Holmes 2020