Learn More

ActionHero is a multi-transport Node.JS API Server with integrated cluster capabilities and delayed tasks.

ActionHero was built from the ground up to include all the features you expect from a modern API framework. This includes all the features listed below and more. ActionHero also knows when to get out of the way to allow you to customize your stack to fit your needs.

Servers

Web

Web Server Docs

ActionHero can act as a HTTP or HTTPS API server. With integrated routing, it is easy to create RESTful resources. ActionHero can also serve static files.

curl "http://127.0.0.1:8080/api/" -d "action=actionsView"
  

Web Socket

Websocket Server Docs

ActionHero uses Primus to provided a robust and reliable nodejs websocket implementation. ActionHero web socket clients can fall back to long-polling and other transports to ensure they are connected. Primus allows you to choose the underlying websocket implementation of your choice.

var A = new ActionheroClient;
A.connect();
A.action("actionsView", function(data){ console.log(data); })
  

Socket

Socket Server Docs

ActionHero ships with the ability to be a line TCP or TLS server. ActionHero clients can speak a wire protocol that sends lines of JSON. Actions can be processed asynchronously and in parallel. The API server and the built-in chat system provide all you need for a communication or game application.

> telnet localhost 5000
Trying 127.0.0.1...
Connected to localhost.
{"welcome":"Hello! Welcome to the actionhero api"}
> say myChatRoom hello
{"ok"}
  

Your Own

Custom Server Docs

Most importantly, ActionHero's modular server architecture allows you to define your own servers and protocols. Learn how in the ActionHero documentation.

Features

Easy-To-Use Actions

Action Docs

With ActionHero, you create 'actions' which can respond to any type of connection. They process incoming parameters and offer a response to the client. ActionHero takes care of routing and responding to each connection type for you.

exports.action = {
  name: 'randomNumber',
  description: 'I generate a random number',
  action.inputs: {
    'required' : [],
    'optional' : []
  },
  outputExample: {randomNumber: 123}
  run: function(api, data, next){
    data.response.randomNumber = Math.random();
    next();
  }
}
  

Built-In Tasks

Task Docs

Background tasks are first-class citizens in ActionHero. You can enqueue a task from anywhere in the application. Tasks can be recurring or single-run. ActionHero's task system is powered by Resque, so it is compatible with a number of other applications and frameworks.

api.tasks.enqueue(
    "sendWelcomeEmail",
    {to: 'evan@evantahler.com'},
    'default',
function(error, toRun){
  // done!
});

var task = {
  name:          "sendWelcomeEmail",
  description:   "I will send a new user a welcome email",
  queue:         "default",
  frequency:     0,
  run: function(api, params, next){
    api.sendEmail(params.email, function(error){
      if(error){ api.log(error, 'error'); }
      next();
    })
  }
};
  

Cluster-Ready

Action Cluster Docs

ActionHero uses Redis to store and share data. With first-class cache functions, decentralized communications, and distributed workers, you can be sure that your application is able to scale from 1 worker on one server, to as big of a cluster as you need.

Multiple Servers and Transports

Introduction Docs

The ActionHero API makes it simple to create a traditional HTTP(S) API, but it also lets you easily extend your API to TCP and websocket clients (all included). ActionHero also easily lets you write your own servers to handle custom transports.

Routing

Route Docs

ActionHero ships with a router to make mapping HTTP requests to your actions a breeze.

API First Development

www.api-first.com

ActionHero makes API-First development very easy by enforcing a strict separation of views and application logic. ActionHero also makes modularizing your application easy with simple clustering and easy-to-use background tasks.

Chat

Chat Docs

ActionHero (optionally) facilitates real-time communication not only from server-to-client, but also client-to-client! ActionHero's chat sub-system allows for streaming of both public and private messages between clients. Complete with middleware and extensions, you can create chat services, multi-player games, and more!

Clustered Deployment

Deployment Docs

It is simple to deploy ActionHero with our included binaries. You can launch your server as a single instance or as part of a node.js cluster.

File Server

File Server Docs

Every respectable framework needs to serve files to its clients (even those that don't speak HTTP), and ActionHero is no exception. Configured to asynchronously stream file contents, ActionHero provides an excellent file server which can live in parallel with your API routes allowing for a fully featured server. No nginx required!

Localization

Localization Docs

ActionHero is integrateed with `i18n` to allow you to customize every string in the server, from action responses to logging to fit your (and your user's) needs.

Community

Resources

Downloads

Learn

Companies Using ActionHero