Gem Version Build Status Code Climate

OneSignal is a simple ruby wrapper for the OneSignal API.


Add this line to your application's Gemfile:

gem 'onesignal'

And then execute:

$ bundle

Or install it yourself as:

$ gem install onesignal


You can find your auth keys and app IDs on the Account Management page when you're logged into OneSignal. With those at hand, you can create a client.

client = 'AUTH_TOKEN', app_id: 'APP_ID')


This gem follows a strict design of resources as methods on your client. For examples, for apps, you will call your client like this:

client = 'AUTH_TOKEN')
client.apps #=> AppResource

It will return objects that contain the information provided by the API. For example:

client = 'AUTH_TOKEN')
# => [ OneSignal::App(id: '92911750-242d-4260-9e00-9d9034f139ce', name: 'Your App 1', ...), OneSignal::App(id: 'e4e87830-b954-11e3-811d-f3b376925f15', name: Your app 2', ...) ]

To retrieve objects, you can perform this type of action on the resource (if the API supports it):

client = 'AUTH_TOKEN')
app = client.apps.find(id: 'e4e87830-b954-11e3-811d-f3b376925f15')
# => OneSignal::App(id: 'e4e87830-b954-11e3-811d-f3b376925f15', name: 'Your app', ...)

To create objects, you just have to build a params hash and pass it to the action on the resource:

client = 'AUTH_TOKEN')
params = { name: 'Your app', apns_env: 'sandbox', ... }
app = client.apps.create(params)
# => OneSignal::App(id: 'e4e87830-b954-11e3-811d-f3b376925f15', name: 'Your app', ...)

All Resources and actions

App resource

client = 'AUTH_TOKEN')
client.apps #=> OneSignal::AppResource

Actions supported:

  • client.apps.all
  • client.apps.find(id)
  • client.apps.create(params)
  • client.apps.update(id, params)

Player resource

client = 'AUTH_TOKEN', app_id: 'APP_ID')
client.players #=> OneSignal::PlayerResource

Actions supported:

  • client.players.all
  • client.players.all(params)
  • client.players.find(id)
  • client.players.create(params)
  • client.players.update(id, params)
  • client.players.on_session(id, params)
  • client.players.on_purchase(id, params)
  • client.players.on_focus(id, params)
  • client.players.csv_export(id)

Notification resource

client = 'AUTH_TOKEN', app_id: 'APP_ID')
client.notifications #=> OneSignal::NotificationResource

Actions supported:

  • client.notifications.all
  • client.notifications.all(params)
  • client.notifications.find(id)
  • client.notifications.track_open(id, params)
  • client.notifications.create(params)
  • client.notifications.cancel(id)


Bug reports and pull requests are welcome on GitHub.

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.