Skip to content
Hipflag Ruby client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status

Hipflag logo

This gem is a Ruby client for interacting with Hipflag API.

Hipflag is a tool that allows to control and roll out new product features with flags. It offers a simple UI to enable/disable feature flags. It also let users to enable flags for a given percentage of users


Add this line to your application's Gemfile:

gem 'hipflag'

or install it yourself as:

$ gem install hipflag


Initializing a client

The client can be configured globally:

Hipflag.configure do |config|
  config.public_key = '**************'
  config.secret_key = '**************'

or by instance: '*******', secret_key: '*******')

Client methods

Clients methods returns a Hipflag::Response object. This kind of objects contain methods to get the status of the request (ie: #ok?, #created?, ...) and a method called #json which returns a JSON representation of the response.



It returns relevant information about a specific flag



  'flag' => {
    'active' => true,
    'name' => 'new-header'

It is possible to pass a user_id to check if the flag is enabled for that given user:

client.flag('new-header', user_id: 123).json

If a flag is not found, the client raises a Hipflag::Client:NotFound exception. Example:


Exception raised:

Hipflag::Client::NotFound: Resource not found
#update_flag(flag_id, params)

This method updates a specific flag

client.update_flag('new-header', rollout: 75).json


  'flag' => {
    'enabled' => true,
    'rollout' => 75,
    'name' => 'new-header'
client.update_flag('new-header', enabled: false).json


  'flag' => {
    'enabled' => false,
    'rollout' => 75,
    'name' => 'new-header'

If Hipflag cannot update a flag because a param is not valid, the client raises an exception including the error message. For example:

client.update_flag('new-header', rollout: 500).json

Exception raised

Hipflag::Client::UnprocessableEntity: {"message"=>{"rollout"=>["must be less than or equal to 100"]}}

You can get the list of editable attributes in the documentation.

Client errors

Hipflag::Client methods can raise several exceptions when performing requests:

  • Hipflag::Client::Unauthorized: Request is not properly authenticated
  • Hipflag::Client::ServerError: Hipflag API is not responding
  • Hipflag::Client::NotFound: Resource is not found (404)
  • Hipflag::Client::UnprocessableEntity: Request could not be processed

How to retrieve the authentication keys

You can get your personal Publicand Secret keys at

How to using in Rails

The best way to use the client in a Rails application is adding a initializer: config/initializers/hipflag.rb:

Hipflag.configure do |config|
  config.public_key = '**************'
  config.secret_key = '**************'

Then you can instantiate the client already containing the configuration:
=> #<Hipflag::Client:0x00007faa173be430 @public_key="**********", @secret_key="**********">


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License

You can’t perform that action at this time.