npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rakuten

v0.0.3

Published

An unofficial node.js client library for Rakuten Web Service API

Downloads

7

Readme

node-rakuten

Build Status

An unofficial Node.js client library for Rakuten Web Service API.

Installation

Install from npm, the Node.js package manager:

$ npm install rakuten

Example

Search for items by keyword iphone6:

var rakuten = require('rakuten');
var item = rakuten.ichiba.item('2014-02-22');

var params = {
  applicationId: 'YOUR_APPLICATION_ID',
  keyword: 'iphone6'
};

item.search(params, function(err, res) {
  console.log(res.count + ' items found!');
});

See full list of examples placed under examples directory. To run examples, you'll need to have at least one Rakuten API App and pass your own applicationId to examples/config.json as a property.

Usage

Creating a client

Create a client object for the particular service provided by Rakuten Web Service API. For example, to use the Rakuten Ichiba Ranking API version 2012-09-27:

var rakuten = require('rakuten');
var ranking = rakuten.ichiba.ranking('2012-09-27');

Using application ID

You may need to pass application ID to interact with an API. The following example makes a request to Rakuten Ichiba Item Search API with an application ID and keyword iphone6 :

var rakuten = require('rakuten');
var item = rakuten.ichiba.item('2014-02-22');

var params = {
  applicationId: 'YOUR_APPLICATION_ID',
  keyword: 'iphone6'
};

item.search(params, function(err, res) {
  console.log(res.count + ' items found!');
});

To get an application ID visit your application list page.

Authentication

In order to access private data such as Favorite Bookmarks, you will need to have authorization through Rakuten OAuth 2.0 API.

Create OAuth 2.0 client

This library contains simple OAuth 2.0 client. Obtain auth credentials, client ID and client secrete from registered application and pass them to the client with your authorization redirect URI.

var rakuten = require('rakuten');
var OAuth2Client = rakuten.auth.OAuth2;
var client = OAuth2Client({
  client_id: 'APPLICATION_ID',
  client_secret: 'APPLICATION_SECRET',
  redirect_uri: 'REDIRECT_URI'
});

Authorization URL

To ask for permissions from a user to retrieve an access token, you redirect them to a consent page. Be sure to include the scope that asks permissions for services. To create a consent page URL:

var url = client.generateAuthURL('rakuten_favoritebookmark_read');
console.log('Visit the url from browser: ' + url)

Get access token

With the code returned, you can ask for an access token through getAccessToken as shown below:

client.getAccessToken(code, function(err, tokens) {
  if (!err) {
    console.log(tokens.access_token);
  }
});

A complete sample application that authorizes and authenticates with the OAuth2 client is available at examples/bookmark-*.js.

Options

For all API calls we use mikeal/request object and you can pass any available options in to it. For example, specifing a default proxy and timeout with 5000 milliseconds:

var rakuten = require('rakuten');
rakuten.options({
  proxy: 'http://localproxy.com',
  timeout: 5000
});
var item = rakuten.ichiba.item('2014-02-22');

A full list of supported options can be found here.

API

The following APIs and versions are currently supported:

Ichiba

  • ichiba.item - Ichiba Item Search API (versions: 2014-02-22)
  • ichiba.genre - Ichiba Genre Search API (versions: 2014-02-22)
  • ichiba.tag - Ichiba Tag Search API (versions: 2014-02-22)
  • ichiba.ranking - Ichiba Item Ranking API (versions: 2012-09-27)
  • ichiba.itemcode - Ichiba Item Search API (versions: 2010-08-05)
  • ichiba.product - Ichiba Item Search API (versions: 2014-03-05)

Books

  • books.item - Books Item Search API (versions: 2013-05-22)
  • books.book - Books Book Search API (versions: 2013-05-22)
  • books.cd - Books CD Search API (versions: 2013-05-22)
  • books.dvd - Books DVD & Blu-ray API (versions: 2013-05-22)
  • books.foreignbook - Books Foreign Book Search API (versions: 2013-05-22)
  • books.magazine - Books Magazine Search API (versions: 2013-05-22)
  • books.game - Books Game Search API (versions: 2013-05-22)
  • books.software - Books Software Search API (versions: 2013-05-22)
  • books.genre - Books Genre Search API (versions: 2012-11-28)

Auction

  • auction.genre - Auction Genre Search API (versions: 2012-09-27)
  • auction.genrekeyword - Auction Genre Keyword Search API (versions: 2012-09-27)
  • auction.item - Auction Item Search API (versions: 2013-09-05)
  • auction.itemcode - Auction Item Code Search API API (versions: 2012-10-10)

Travel

  • travel.hotelsimple - Travel Hotel Simple Search API (versions: 2013-10-24)
  • travel.hoteldetail - Travel Hotel Detail Search API (versions: 2013-10-24)
  • travel.hotelvacant - Travel Vacant Hotel Search API (versions: 2013-10-24)
  • travel.area - Travel Area API (versions: 2013-10-24)
  • travel.hotelkeyword - Travel Hotel Keyword Search API (versions: 2013-10-24)
  • travel.hotelchain - Travel Hotel Chain API (versions: 2013-10-24)
  • travel.hotelranking - Travel Hotel Ranking API (versions: 2013-10-24)

Bookmark

  • bookmark - Favorite Bookmark API (versions: 2012-06-27)

Recipe

  • recipe.category - Recipe Category API (versions: 2012-11-21)
  • recipe.ranking - Recipe Ranking API (versions: 2012-11-21)

Kobo

  • kobo.ebook - Kobo E-Book Search API (versions: 2014-08-11)
  • kobo.genre - Kobo Genre Search API (versions: 2013-10-10)

Gora

  • gora.course - GORA Golf Course Search API (versions: 2013-11-13)
  • gora.coursedetail - GORA Golf Course Detail API (versions: 2014-04-10)
  • gora.plan - GORA Golf Plan Search API (versions: 2014-04-10)

Dynamic Ad

  • dynamicad.ichiba - Not implemented yet
  • dynamicad.travel - Not implemented yet

Affiliate

  • affiliate.highcommissionshop - Affiliate High Commission Shop API (versions: 2013-12-05)

Licence

Distributed under the MIT License.