RunKit EndpointBuild APIs without any servers

Note: This is a beta release! We may make changes as Endpoint develops.

Endpoint is a fast and simple way to write code with Node.js that can respond to HTTP requests from anywhere. There's no need to manage servers or deployments, instead just write code in RunKit. Getting started is as easy as implementing one function. Here's a simple example:

The code above is now a real running endpoint. Changes will be reflected in real time. And just like with any notebook, you can (and should!) publish permanent versions as you develop your APIs. Go ahead, try curling it:

The Details

Any RunKit document that exports a function called endpoint can serve requests. The function should have the same signature as the callback passed to server.listen in node directly. The only change here is removing the explicit server creation and port binding.

Notebooks access through endpoint are hosted on runkit.io and each user has their own subdomain. Unlike the main notebook page, which has a shorthand for accessing the latest revision, you'll just need to specifically reference /branches/master. Being explicit has an advantage; it means that not only will your notebook respond to urls like:

You can use the environment variable process.env.RUNKIT_MOUNT_PATH to programatically check the base path of your endpoint, and process.env.RUNKIT_ENDPOINT_URL to get the base URL of your endpoint.

Examples

Simple JSON API

Want to build a simple API that sends/receives JSON messages, without dealing with HTTP at all? We built a simple helper for this that sets it up for you. You can see how the helper is implemented, or check out this usage example. You can also return a promise directly, or use a done callback.

Using Endpoint with Express

We've built a simple wrapper to set up a fully compatible Express app with Endpoint. Just require our wrapper instead of express, and pass in the exports object to your app constructor. You can see how the helper is implemented, or check out this usage example.

Restrictions

The main restriction is that cookie headers will be filtered out of requests and responses. This is to prevent malicious endpoints from attempting to attack other endpoints that might insecurely use cookies. Certain other security related headers are also filtered. Endpoint is only available over https.

Although RunKit let's you use a top level await at any time, you can't use a top level await before exporting your endpoint function.

Requests must terminate within 60 seconds. Endpoints are rate limited, and during the beta period they are restricted to non-commercial use. If you need to raise rate limits, or would like to use Endpoint commercially, just get in touch.