All Projects → rakuten-ws → Rws Ruby Sdk

rakuten-ws / Rws Ruby Sdk

Licence: mit
Ruby Client for Rakuten Web Service

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Rws Ruby Sdk

Matestack Ui Core
Matestack enables you to create sophisticated, reactive UIs in pure Ruby, without touching JavaScript and HTML. You end up writing 50% less code while increasing productivity, maintainability and developer happiness.
Stars: ✭ 469 (+465.06%)
Mutual labels:  hacktoberfest, rubygem
Docx
a ruby library/gem for interacting with .docx files
Stars: ✭ 288 (+246.99%)
Mutual labels:  hacktoberfest, rubygem
Fab Speed Dial
Angular Material FAB speed dial
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
Node Mongodb Fixtures
🍏 Setup and tear down test fixtures with MongoDB.
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest
Free Certifications
Curated list of free courses & certifications
Stars: ✭ 1,241 (+1395.18%)
Mutual labels:  hacktoberfest
Graphql Doctrine
Automatic GraphQL types from Doctrine entities
Stars: ✭ 81 (-2.41%)
Mutual labels:  hacktoberfest
Bioconda Recipes
Conda recipes for the bioconda channel.
Stars: ✭ 1,247 (+1402.41%)
Mutual labels:  hacktoberfest
Binari
Interactive code editor with a live binary tree visual designed to teach new developers the fundamentals of dynamic programming.
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
Rstfinder
Fast Discourse Parser to find latent Rhetorical STructure (RST) in text.
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest
React Native Merlin
🧙 Simple web-like forms in react native.
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest
Wiki
Archive of free60.org mediawiki
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest
Avro Builder
Ruby DSL to create Avro schemas
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
Doctor Command
Diagnose problems within WordPress by running a series of checks for symptoms
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
C
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
Stars: ✭ 11,897 (+14233.73%)
Mutual labels:  hacktoberfest
Travel Guide
"A travel guide to suggest activities you can do once you arrive to a certain destination. Or you can just browse destinations and check out the different available activities."
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
Fog Google
Fog for Google Cloud Platform
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest
Shlink Web Client
A React-based client application for Shlink
Stars: ✭ 81 (-2.41%)
Mutual labels:  hacktoberfest
Acex
ACE3 Extra misc modules and components
Stars: ✭ 82 (-1.2%)
Mutual labels:  hacktoberfest
Monday
⚡️ A dev tool for microservice developers to run local applications and/or forward others from/to Kubernetes SSH or TCP
Stars: ✭ 1,246 (+1401.2%)
Mutual labels:  hacktoberfest
Puppet Php
Generic Puppet module to manage PHP on many platforms
Stars: ✭ 83 (+0%)
Mutual labels:  hacktoberfest

RakutenWebService

CI Build Status Gem Version Test Coverage Code Climate Gitter

This gem provides a client for easily accessing Rakuten Web Service APIs.

日本語のドキュメントはこちら

Table of Contents

Prerequisite

  • Ruby 2.5 or later

Installation

Add this line to your application's Gemfile:

gem 'rakuten_web_service'

And then execute:

bundle

Or install it yourself as:

gem install rakuten_web_service

Usage

Prerequisite: Getting Application ID

You need to get Application ID for your application to access to Rakuten Web Service APIs. If you have not got it, register your application here.

Configuration

At first, you have to specify your application's key. And you can tell the client your afiiliate id with RakutenWebService.configure.

In Your Code

  RakutenWebService.configure do |c|
    # (Required) Appliction ID for your application.
    c.application_id = 'YOUR_APPLICATION_ID'

    # (Optional) Affiliate ID for your Rakuten account.
    c.affiliate_id = 'YOUR_AFFILIATE_ID' # default: nil

    # (Optional) # of retries to send requests when the client receives
    # When the number of requests in some period overcomes the limit, the endpoints will return
    # too many requests error. Then the client tries to retry to send the same request after a
    # while.
    c.max_retries = 3 # default: 5

    # (Optional) Enable debug mode. When set true, the client streams out all HTTP requests and
    # responses to the standard error.
    c.debug = true # default: false
  end

Please note that you need to replace 'YOUR_APPLICATION_ID' and 'YOUR_AFFILIATE_ID' with actual ones you have.

Environment Variables

You can configure application_id and affiliate_id by defining environment variables RWS_APPLICATION_ID and RWS_AFFILIATION_ID.

Search Ichiba Items

  items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby') # This returns Enumerable object
  items.first(10).each do |item|
    puts "#{item['itemName']}, #{item.price} yen" # You can refer to values as well as Hash.
  end

Pagerizing

Responses of resources' search such as RakutenWebService::Ichiba::Item.search have methods for paginating fetched resources.

  items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby')
  items.count #=> 30. In default, the API returns up to 30 items matched with given keywords.

  last_items = items.page(3) # Skips first 2 pages.

  # Go to the last page
  while last_items.next_page?
    last_items = last_items.next_page
  end

  # Shows the title of the last 30 items
  last_items.each do |item|
    puts item.name
  end

  # Easier way to fetch all resources page 3 and latter
  items.page(3).all do |item|
    puts item.name
  end

Genre

Genre class provides an interface to traverse sub genres.

  root = RakutenWebService::Ichiba::Genre.root # root genre
  # children returns sub genres
  root.children.each do |child|
    puts "[#{child.id}] #{child.name}"
  end

  # Use genre id to fetch genre object
  RakutenWebService::Ichiba::Genre[100316].name # => "水・ソフトドリンク"

Ichiba Item Ranking

  ranking_by_age = RakutenWebService::Ichiba::Item.ranking(age: 30, sex: 1) # returns the TOP 30 items for Male in 30s
  # For attributes other than 'itemName', see: http://webservice.rakuten.co.jp/api/ichibaitemsearch/#outputParameter
  ranking_by_age.each do |ranking|
    puts item.name
  end

  ranking_by_genre = RakutenWebService::Ichiba::Genre[200162].ranking # the TOP 30 items in "水・ソフトドリンク" genre
  ranking_by_genre.each do |ranking|
    puts item.name
  end

Recipe

  categories = RakutenWebService::Recipe.small_categories

  # Search all small recipe categories.
  categories.each do |category|
    category.name
  end

  recipes = categories.first.ranking

  # Search category recipes.
  recipes.each do |recipe|
    recipe.title
  end

Supported APIs

Now rakuten_web_service is supporting the following APIs:

Rakuten Ichiba APIs

Rakuten Books APIs

Rakuten Kobo APIs

Rakuten Recipe APIs

Rakuten GORA APIs

Rakuten Travel APIs

Contributing

  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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].