This is the documentation for the Ruby client for Objectia® 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 Objectia 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 objectia-ruby is from RubyGems.

gem install objectia

Or, you can clone the source code for objectia-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 objectia.


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

require "objectia"


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


If you do not have an API Key, you can easily generate one by heading over to the API settings page.

Error handling

Handle errors with a rescue block:

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

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