This is the documentation for the Ruby client for Salesfly® API. You can find the source code for the client on GitHub. We have API clients in several other programming languages hosted on GitHub.


The Ruby client for Salesfly API requires Ruby version 2.2 or later. If you’re using a Mac or Linux machine, you probably already have Ruby installed. You can check this by opening up a terminal and running the following command:

ruby --version

You should see something like:

$ ruby --version
ruby 2.5.4

Windows users can use RubyInstaller to install Ruby.


The easiest way to instal salesfly-ruby is from RubyGems.

gem install salesfly

Or, you can clone the source code for salesfly-ruby, and install the library from there.


If the command line gives you a long error message that says Permission Denied in the middle of it, try running the above commands with sudo: sudo gem install salesfly.


Now that we have Ruby and salesfly-ruby installed, we can start using the API. In the example below we will look up the geolocation of the IP address

require "salesfly"


client ={
    api_key: api_key,
location = client.geoip.get("")
print "Country code: ", location["country_code"]

Error handling

Handle errors with a rescue block:

# If you enter an invalid IP address, you get an error
    location = client.geoip.get("x")
rescue Salesfly::ResponseError => e
    if e.code == "err-invalid-ip"
		# Handle error...
		# Other error...

You will find all the error codes in the REST API documentation.