{"id":42351644,"url":"https://github.com/recombee/ruby-api-client","last_synced_at":"2026-01-27T16:06:40.881Z","repository":{"id":56891352,"uuid":"58161891","full_name":"recombee/ruby-api-client","owner":"recombee","description":"Ruby client for easy use of the Recombee recommendation API","archived":false,"fork":false,"pushed_at":"2025-10-23T14:12:31.000Z","size":294,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T04:20:55.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recombee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-05T21:31:00.000Z","updated_at":"2025-10-23T14:12:29.000Z","dependencies_parsed_at":"2025-01-14T14:35:15.334Z","dependency_job_id":"00e841a7-df36-4d89-940c-a8a30f0aa3e8","html_url":"https://github.com/recombee/ruby-api-client","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"a5fe6d9645529090d04a00a4510bf1647a7472a0"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/recombee/ruby-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fruby-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fruby-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fruby-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fruby-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recombee","download_url":"https://codeload.github.com/recombee/ruby-api-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fruby-api-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28816519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-27T16:06:40.273Z","updated_at":"2026-01-27T16:06:40.870Z","avatar_url":"https://github.com/recombee.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RecombeeApiClient\n\nA Ruby client for easy use of the [Recombee](https://www.recombee.com/) recommendation API.\n\nIf you don't have an account at Recombee yet, you can create a free account [here](https://www.recombee.com/).\n\nDocumentation of the API can be found at [docs.recombee.com](https://docs.recombee.com/).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'recombee_api_client'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install recombee_api_client\n\n## Examples\n\n### Basic example\n```ruby\nrequire 'recombee_api_client'\ninclude RecombeeApiClient\n\nclient = RecombeeClient.new('--my-database-id--', '--db-private-token--', {:region =\u003e 'us-west'})\n\n# Generate some random purchases of items by users\nNUM = 100\nPROBABILITY_PURCHASED = 0.1\n\nusers = (1..NUM).map { |i| \"user-#{i}\" }\nitems = (1..NUM).map { |i| \"item-#{i}\" }\npurchases = []\n\nusers.each do |user_id|\n  purchased = items.select { |_| rand(0.0..1.0) \u003c PROBABILITY_PURCHASED }\n  purchased.each { |item_id| purchases.push(\n\n                AddPurchase.new(user_id, item_id,'cascadeCreate' =\u003e true)\n                                                  # Use cascadeCreate to create the\n                                                  # yet non-existing users and items\n                )}\n\nend\n\nbegin\n  # Send the data to Recombee, use Batch for faster processing of larger data\n  client.send(Batch.new(purchases))\n  \n  # Get recommendations for user 'user-25'\n  response = client.send(RecommendItemsToUser.new('user-25', 5))\n  puts \"Recommended items for user-25: #{response}\"\n\n  # User scrolled down - get next 3 recommended items\n  response = client.send(RecommendNextItems.new(response['recommId'], 3))\n  puts \"Next recommended items for user-25: #{response}\"\n\nrescue APIError =\u003e e\n  puts e\n  # Use fallback\nend\n```\n\n### Using property values\n```ruby\nrequire 'recombee_api_client'\ninclude RecombeeApiClient\n\nNUM = 100\nPROBABILITY_PURCHASED = 0.1\n\nclient = RecombeeClient.new('--my-database-id--', '--db-private-token--', {:region =\u003e 'ap-se'})\nclient.send(ResetDatabase.new) # Clear everything from the database (asynchronous)\n\n# We will use computers as items in this example\n# Computers have five properties \n#   - price (floating point number)\n#   - number of processor cores (integer number)\n#   - description (string)\n#   - date from which it is in stock (timestamp)\n#   - image (url of computer's photo)\n\n# Add properties of items\nclient.send(AddItemProperty.new('price', 'double'))\nclient.send(AddItemProperty.new('num-cores', 'int'))\nclient.send(AddItemProperty.new('description', 'string'))\nclient.send(AddItemProperty.new('in_stock_from', 'timestamp'))\nclient.send(AddItemProperty.new('image', 'image'))\n\n# Prepare requests for setting a catalog of computers\nrequests = (1..NUM).map do |i|\n  SetItemValues.new(\n      \"computer-#{i}\", #itemId\n      #values:\n      { \n        'price' =\u003e rand(15000.0 .. 25000.0),\n        'num-cores' =\u003e rand(1..8),\n        'description' =\u003e 'Great computer',\n        'in_stock_from' =\u003e DateTime.now,\n        'image' =\u003e \"http://examplesite.com/products/computer-#{i}.jpg\"\n      },\n      #optional parameters:\n      {\n        :cascade_create =\u003e true  # Use cascade_create for creating item\n                                 # with given itemId, if it doesn't exist\n      }\n    )\nend\n\n# Send catalog to the recommender system\nputs client.send(Batch.new(requests))\n\n# Prepare some purchases of items by users\nrequests = []\n(1..NUM).map{|i| \"computer-#{i}\"}.each do |item_id|\n  user_ids = (1..NUM).map{|i| \"user-#{i}\"}\n  user_ids = user_ids.select { |_| rand(0.0..1.0) \u003c PROBABILITY_PURCHASED }\n  # Use cascade_create to create unexisting users\n  user_ids.each { |user_id| requests.push(AddPurchase.new(user_id, item_id, :cascade_create =\u003e true)) }\nend\n\n# Send purchases to the recommender system\nclient.send(Batch.new(requests))\n\n# Get 5 recommendations for user-42, who is currently viewing computer-6\n# Recommend only computers that have at least 3 cores\nrecommended = client.send(\n  RecommendItemsToItem.new('computer-6', 'user-42', 5, {:filter =\u003e \"'num-cores'\u003e=3\"})\n  )\nputs \"Recommended items with at least 3 processor cores: #{recommended}\"\n\n# Recommend only items that are more expensive then currently viewed item (up-sell)\nrecommended = client.send(\n  RecommendItemsToItem.new('computer-6', 'user-42', 5,\n    {:filter =\u003e \"'price' \u003e context_item[\\\"price\\\"]\"})\n  )\nputs \"Recommended up-sell items: #{recommended}\"\n\n# Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)\n# when scenario is specified\nrecommended = client.send(\n  RecommendItemsToItem.new('computer-6', 'user-42', 5, {:scenario =\u003e 'product_detail'})\n  )\n\n# Perform personalized full-text search with a user's search query (e.g. 'computers').\nmatches = client.send(\n  SearchItems.new('user-42', 'computers', 5, {:scenario =\u003e 'search_top'})\n  )\nputs \"Matched items: #{matches}\"\n```\n\n### Exception handling\n\nFor the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.\n\nWe are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.\n\nExample:\n```ruby\n\nbegin\n  recommended = client.send(\n    RecommendItemsToItem.new('computer-6', 'user-42', 5,\n    {'filter' =\u003e \"'price' \u003e context_item[\\\"price\\\"]\"})\n  )\nrescue ResponseError =\u003e e\n  # Handle errorneous request =\u003e use fallback\nrescue ApiTimeout =\u003e e\n  # Handle timeout =\u003e use fallback\nrescue APIError =\u003e e\n  # APIError is parent of both ResponseError and ApiTimeout\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecombee%2Fruby-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecombee%2Fruby-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecombee%2Fruby-api-client/lists"}