Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (70 sloc) 3.293 kb

Package Goal

The goals of this package are to support:

  • Well-designed APIs (easy to use, scales well, easy to extend, etc)
  • Simple usage of any API from any programming language. (Its pretty easy already, but we make it even easier)
  • Full support for running an API as a service on Linux and Windows operating systems
  • Simplicity of development for both API authors and consumers

Reasons to use PerfectAPI (Current Feature list)

  • You want to expose an API using Node.js, or you want to make an existing Node.js module accessible as a remote service API
  • You care about performance - 4 times faster than node-restify
  • Easily create a self-hosted server with command-line - myapp server -p 3002
  • Support for easy configuration via environment variables
  • Awesomely amazing test page for your users to learn/experiment/test your API, e.g. amigen api test page
  • Windows and Linux installers (run your API as a true service on your server) - myapp install myappservicename
  • Automatic validation of required parameters (no need to code boring validation)
  • Local command-line access to your API
  • Built-in JSONP interface to your API - that means you can access it using JavaScript from another domain
  • REST-like interface to your API
  • Native .NET client to your API - access from .NET without dealing with REST, JSON, WebRequest etc.
  • Built-in support for max-age and etag server caching - lowers your costs by doing less work

Is it Perfect?

No. See the FAQ


The usual for Node.js stuff

$ npm install perfectapi

or for a global install:

$ sudo npm install -g perfectapi

How to include in your API

First, create a perfectapi.json configuration file. See Configuration File for details. Once you have a configuration file, a sample usage is:

#!/usr/bin/env node

var perfectapi = require('perfectapi');  
var path = require('path');

var configPath = path.resolve(__dirname, 'perfectapi.json');
var parser = new perfectapi.Parser();

//handle the commands
parser.on("mycommand", function(config, callback) {
    //do mycommand code, putting results into "result" object

    //after done
    callback(err, result);

parser.on("anothercommand", function(config, callback) {
    //do anothercommand code, putting results into "result" object

    //after done
    callback(err, result);

//expose the api
module.exports = parser.parse(configPath);

In your package.json file, be sure to specify the above file as a "bin", so that the app can be called from the command-line, e.g.

{ "name": "myNodeLib"
, "version": "0.0.1"
, "description": "My brilliant API"
, "main": "./bin/myNodeLib.js"
, "bin": "./bin/myNodeLib.js"
, "engines": {
    "node" : ">=0.6.5"
, "dependencies": {
    "perfectapi": ">=0.0.13"

Thats it.

See the website and wiki for more info.

Jump to Line
Something went wrong with that request. Please try again.