node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Talk to a remote API without needing to expose your secret token or all the API endpoints

The problem

Distillery was created to secure the communication with a remote APIs from the browser.

To talk to public APIs, (i.e.: Instagram, Twitter, etc.) you need a secret token which gives you access to the API endpoints. You can't let other people know about this secret token, or they could do nasty things to your account.

Distillery is a NodeJS library that proxies the API calls through, while hiding your secret token. You can also specify what methods and specific endpoints you want to deny or allow access to.


Use npm to install it in your project:

$ npm install distillery

Or clone it using git:

$ git clone

Or download it from github

Instagram API Example Server

Example configuration:

// config.json
  "services": {
    "instagram": {
      "remoteUrl": "",
      "auth": {
        "method": "get",
        "key": "client_id",
        "value": "cfxxxxxxxxxxxxxxxxxxxxxxxxxxxx13"
      "rules": {
        "deny": {
          "methods": ["post", "put"],
          "paths": ["users/search"]

Run the server:

$ node server.js
Express + Distillery server is running on port 3000

Or use it like a library:

var express     = require("express"),
    app         = express(),
    config      = require("./config"),
    Distillery  = require("distillery");
var distillery_app = new Distillery(config, app);

Consume the API:

$ curl "http://localhost:3000/instagram/media/popular"
  "meta": {
    "code": 200
  "data": [
      "attribution": null,
      "tags": [],
      "location": null,
      "comments": {
        "count": 48,
        "data": [

View example in codepen: (You must be locally running the distillery server on port 3000)

Trying to access blocked paths or methods will return a 404 error:

$ curl "http://localhost:3000/instagram/users/search?q=jorge"
  "error": "Endpoint not found"


TODO (See the test directory for implementation details)


  • Support standard (and popular APIs) ways of authenticating
  • Improve the way deny/allow works
  • Switch to a lighter HTTP server (replace express)