Giter Site home page Giter Site logo

tamber-ruby's Introduction

Tamber API Client for Ruby Build Status

Recommendation engines for developers, easy as π. Build blazing fast, head-scratchingly accurate hosted recommendation engines in minutes.

The Tamber iOS SDK makes it easy to track events (user-item interactions) and get recommendations for your users in real time.

Get a free api key to get started.

Documentation

See full API documentation.

Installation

To use the Tamber Ruby bindings, you should run:

gem install tamber

If you want to build the gem from source:

gem build tamber.gemspec

Compatibility

We are compatible with Ruby 1.9.3 and above.

Usage

If you are just getting started, check out the Quick Start guide for instructions on how to get setup.

We recommend tracking events from the client-side so that Tamber can learn from clicks/views, guest users, and contextual data. Use our iOS, Node, or javascript SDKs to start tracking.

Of course, you can also track events from your backend.

Track Events

require 'tamber'
Tamber.project_key = 'your_project_key'

begin
  Tamber::Event.track(
    user: 'user_rlox8k927z7p',
    behavior: 'like'
    item:  'item_wmt4fn6o4zlk',
    context: {
      "page": "homepage", 
      "section": "featured_section"
    }
  )
rescue TamberError => error
  puts error.message
end

Get Recommendations

Once you have tracked enough events and created your engine, it's time to put personalized recommendations in your app.

The primary methods of discovery in Tamber are the Discover.next and Discover.recommended methods, which returns the optimal set of items that the user should be shown next on a given item page, and in a personalized recommendations section, respectively.

Up Next

Don't make an item page a dead-end. Keep users engaged by creating paths of discovery as they navigate from item to item, always showing the right mix of items they should check out next. Just supply the user and the item that they are navigating to / looking at.

begin
  d = Tamber::Discover.next(
    user: 'user_rlox8k927z7p',
    item: 'item_wmt4fn6o4zlk',
    number: 14
  )
  d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end

For You

To put personalized recommendations on your homepage, or in any recommended section, just call Discover.recommended with the given user's id and the number of recommendations you want to display.

Tamber.project_key = 'your_project_key'

begin
  d = Tamber::Discover.recommended(
    user: 'user_rlox8k927z7p',
    number: 10
  )
  d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end
continuation

Recommendations are optimized for the exact moment and context of the user at the time of request, but sometimes a user wants to see more recommended items than are shown by default. In order to 'Show More', Tamber supports automatic continuation.

When you want to add more recommendations to those currently displayed to the user, just set the continuation field to true. Tamber will automatically generate the set of items that should be appended to the current user-session's list. The user-session is reset when Discover.recommended or Discover.next is called without continuation.

Tamber.project_key = 'your_project_key'

begin
  d = Tamber::Discover.next(
    user: 'user_rlox8k927z7p',
    number: 10,
    continuation: true
  )
  d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end

Trending

Help your users keep their fingers on the pulse of your platform by showing them the hottest, most popular, newest, or most up-and-coming items.

begin
  d = Tamber::Discover.hot # the hottest (trending) items
  d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
end

begin
  d = Tamber::Discover.popular # the most popular items
end

# BETA endpoints
begin
  d = Tamber::Discover.uac # the most up-and-coming items
end

begin
  d = Tamber::Discover.new # the newest items
end

Build Your Own Features

Tamber allows you to use lower-level methods to get lists of recommended items, similar item matches, and similar items for a given user with which you can build your own discovery experiences. Importantly, these methods return raw recommendation data and are not intended to be pushed directly to users.

begin
  Tamber::Discover::Basic.recommended(user: 'user_rlox8k927z7p').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end

begin
  Tamber::Discover::Basic.Similar(item: 'item_wmt4fn6o4zlk').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end

begin
  Tamber::Discover::Basic.RecommendedSimilar(
    user: 'user_rlox8k927z7p',
    item: 'item_wmt4fn6o4zlk'
  ).each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
rescue TamberError => error
  puts error.message
end

Sync Items (optional)

Keep Tamber in sync with your item data in order to use recommendation filtering. Just call Item.update wherever you create and update items in your backend. If you have a Database module, we recommend adding this method there.

require 'tamber'
Tamber.project_key = 'your_project_key'

begin
  Tamber::Item.update(
    id: 'item_wmt4fn6o4zlk',
    updates: {
      add: {
        properties: {
          'available_large': false,
          'stock': 89
        }
      }
    }
  )
rescue TamberError => error
  puts error.message
end

Timeout Configuration

Open and read timeouts are configurable:

Tamber.open_timeout = 1
Tamber.read_timeout = 5

See Tests for more examples.

tamber-ruby's People

Contributors

ankane avatar exobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tamber-ruby's Issues

Timeout is way too long

We're rescuing Exceptions whenever Tamber fails to deliver a response, but the timeout here:

lib/tamber.rb:43
  @open_timeout = 30
  @read_timeout = 80

is waaay too high. We're waiting more than an entire minute before aborting. I don't think this is expected behavior.

Mind changing it?

Thanks

rest-client conflict with other gems (mailjet).

Tamber dependencies for rest-client is 1 major version behind (currently v2.1). This is causing some conflicts with our codebase which is using mailjet

tamber (0.1.14)
      activesupport (>= 4.2.4)
      json (>= 1.8.1)
      rest-client (~> 1.4)

Any chance this can be updated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.