Skip to main content

Using the Webflow API

In this tutorial you'll learn how to call the Webflow API using Node.js. To follow along, you'll need the following:

Authentication

To authenticate you'll need an API key. To generate an API key for a site you'll be working with, open the site in the Webflow dashboard and navigate to the “Settings” pane. You'll see a section titled “API Access”, where you can generate a new key.

Getting a list of sites

const Webflow = require('webflow-api')
const webflow = new Webflow({ token: api_token });

// Promise <[ Site ]>
const sites = webflow.sites();

sites.then(s => console.log(s));

Getting a list of collections

Before you're able to work with collection items, you'll need the collection id.

const Webflow = require('webflow-api')
const webflow = new Webflow({ token: api_token });

// Promise <[ Collection ]>
const collections = webflow.collections({ siteId: '580e63e98c9a982ac9b8b741' });

collections.then(c => console.log(c));

Adding a new collection item

This is how you add a new collection item that will be live as soon as it's added.

const Webflow = require('webflow-api');
const webflow = new Webflow({ token: api_token });

// Promise <Item>
const item = webflow.createItem({
collectionId: '580e63fc8c9a982ac9b8b745',
fields: {
'name': 'Exciting blog post title',
'slug': 'exciting-post',
'_archived': false,
'_draft': false,
'color': '#a98080',
'author': '580e640c8c9a982ac9b8b778',
'post-body': '<p>Blog post contents...</p>',
'post-summary': 'Summary of exciting blog post',
'main-image': '580e63fe8c9a982ac9b8b749',
},
}, { live: true });

item.then(i => console.log(i));