Skip to content
tcr edited this page Mar 15, 2013 · 38 revisions

Rem is an extensible HTTP client with middleware for Node.js and browsers. Built to power anything REST client, Rem comes with support for popular web services out of the box.

Topics

Overview

Make HTTP requests

Rem can make any kind of HTTP request:

rem.json('http://graph.facebook.com/timcameronryan').headers({
  'X-Custom-Header': '1'
}).get(function (err, content, res) {
  if (err) {
    console.error(err);
  } else {
    console.log('Returned this JSON:', content);
  }
})

In addition to json, Rem supports returning content as a stream, buffer, text, xml (with libxmljs), and form data.

Writing API Clients

Rem is customizable for making simple API clients. For example, to make a Tumblr library:

var tumblr = rem.createClient({
  "base": "http://api.tumblr.com/v2",
  "configParams": {"api_key": "key"},
  "uploadFormat": "form"
}).configure({
  "key": process.env.TUMBLR_KEY
});

// Get info about the "staff" blog
tumblr('blog', 'staff.tumblr.com', 'info').get(function (err, json) {
   console.log('Response', json);
});

Authenticating users

Rem can authenticate users using OAuth and tokens can be saved and restored for running scripts.

Built-in Services

Rem comes with support for a number of APIs built-in, which you can access with the rem.connect(...) method. Read the code examples for more information.