Sunday, May 15th 2016 (over 3 years ago)

The Now API

Guillermo Rauch (@rauchg)

I'm happy to announce the general availability of the Now API.

Head over to the documentation, or read on to learn more about the background behind it and what it can do for you.

When we introduced Now we set out to make a deployment tool for JavaScript projects that was extremely easy to use and gave you instantaneous feedback. Deployments shouldn't block your work and collaboration!

The tool itself is distributed over npm and works as a command-line program, both of which a lot of developers are already intimately familiar with.

However, we also realize that there are many other great ways to deploy apps. You might want to…

  • …deploy with the RUN ▶ button of your compiler
  • …deploy code directly from a web-based environment
  • …deploy dynamically!

In addition, since every Now deployment show you the output of the npm install and npm run build commands in realtime, it's perfectly suitable for:

  • Test execution and continuous integration
  • Build and packaging pipelines
  • …and all kinds of one-off tasks not necessarily attached to a HTTP server
The deployment logs

Your deployment URLs always first show the logs of the build in realtime.
This example shows how Now can be a simple test runner!

So, how does the API work?

In its simplest form, this is how you trigger a deployment with just one HTTP request:

require('request').post('https://api.zeit.co/now/instant', {
headers: { Authorization: `Bearer ${token}` },
body: {
  package: {
    name: 'my-deployment',
    dependencies: { express: 'latest' },
    scripts: { start: 'node index' }
  },
  'index.js': `
    require('express')()
    .get('/', (req, res) => res.send('Hello world!'))
    .listen();
  `
}
}, (err, res, body) => console.log(`Deployed to ${body.host}`));

Easy! package.json and index.js go in, ☁️ goes out.

For a comprehensive list of all endpoints, check out the documentation.

We're looking forward to seeing your creations with the Now API! If you have any questions or feedback, please reach out!