Ruby client for the PerfectAudience API


Ruby client for the Perfect Audience reporting api


Add this line to your application's Gemfile:

gem 'perfecta'

And then execute:

$ bundle

Or install it yourself as:

$ gem install perfecta


Create a new instance of the Perfecta Client

client = do |c| = 'email@ddress'
  c.password = 'password'

This will exchange the credentials for an API token and use this token for all subsequent calls.

You can now use the client instance to query the API.

 List all Campaign Reports

p client.campaign_reports.inspect

Optional Query Parameters include

Name Type
interval ['today','yesterday','last_7_days','last_30_days','lifetime']
start_date 'YYYY-MM-DD'
end_date 'YYYY-MM-DD'
site_id 'the_site_id'
campaign_id 'the_site_id'

and can be used by supplying a hash e.g.

p client.campaign_reports(interval: 'yesterday').inspect

List all Ad Reports

p client.ad_reports.inspect

Any of the additional query parameters from the above table can be supplied as a hash.

List all Conversion Reports

p client.conversion_reports.inspect

Any of the additional query parameters from the above table can be supplied as a hash.

List all Sites

p client.sites.inspect

Show a single Site


List all Campaigns

p client.campaigns.inspect

Show a single Campaign

p client.campaign('CAMPAIGN_ID').inspect

List all Ads


Show a single Ad


List all Segments

p client.segments.inspect

Show a single Segment

p client.segment('SEGMENT_ID').inspect

List all Conversions

p client.conversions.inspect

Show a single Conversion

p client.conversion('CONVERSION_ID').inspect


  1. Flesh out the rest of the API
  2. Accept query parameters
  3. Error handling, specifically for when token expires
  4. Relationships and delegation between of objects
  5. Get rid of all the duplication


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request