Webflow API CLI ( WFAPI )

A developer CLI designed to improve your DX with Webflow's API, especially in finding Site, CMS Collection and CMS Item information.

GET QUICKNAV NOW
Sygnal's Webflow API CLI ( WFAPI ) is 100% free and available on NPM..

What Is WFAPI?

Quick Install

Install wfapi directly from npm.

npm install -g @sygnal/wfapi
You can see the package details on NPM's @sygnal/wfapi page.

Generate Your Webflow Workspace Token

  • Go to the Webflow dashboard for the Site you want to access
    • You can access this Site Settings page from the top-left menu in the designer.
  • Click Apps & Integrations on the left menu at the bottom
  • Scroll down to the API access section near the bottom, and click the blue Generate API token button
  • In the modal that appears, give the token the name WFAPI
  • For permissions choose-
    • CMS - read-only
    • Site - read-only
  • Click Generate token
    • You once the token appears, you won't be able to access it again, so I recommend you do the next step carefully before closing the token window.
  • Copy the token, and then from the CLI, type wfapi config set and paste your token. It should look like this.
wfapi config set <your-api-token>

Test Your Setup

Type;

wfapi sites

You should see a list of sites.

The Basics

Working with Sites

List all sites;

wfapi sites

Filter sites- list sites where the name or slug contain test

wfapi sites test

Recent sites filter. To show sites that been created or edited within the past week you can add the --recent option, e.g.;

wfapi sites --recent
wfapy sites acme --recent

Setting a Site Context

Once you know the shortname or ID of a site, you can set it as context with;

wfapi use site <id or slug>

Working with Collections

To list all collections in the current site context;

wfapi cms

Or for specific collections, you can filter with partial text matching the same as you did with sites;

wfapi cms <text match>

Setting a Collection Context

wfapi use cms <id or slug>

Working with Collection Items

To list all items;

wfapi items

Or to filter;

wfapi items <text match>
Currently filtering only works based on partial text matches.

More Options

Most query commands support special options;

  • --recent modified within the past week
  • --raw when you want to see the full JSON response

Mastering Contexts

The examples above demonstrate one axis of context, which we call Use Context.

WFAPI also has another axis, known as Global v. Local Context

By default, you're working in Global context which means that no matter where you are on your system, your API token and your Use Context are shared. Changed either, and they change everywhere.

But what happens when you're working with 10 different client projects each of which use different sites and CMS content?

Using Local Context for Projects

WFAPI allows you to create directory-specific context as well.

To create it, create a blank .wfapi file ( the period in front is important ). This will immediately create a configuration file to store Use Context in any time you use wfapi in that directory.

You can also override the global token by editing the .wfapi file, and adding a token specifier like this;

WEBFLOW_API_TOKEN=(your token)

Create and paste your token using the same instructions as above.

Business Expert
Need help with your project?
We love to code.

Check out our micro-consulting options. You do the the design, we take care of the technical work.

TwitterLinked InBlog