Webflow Python SDK

2.0.0 · active · verified Thu Apr 16

The Webflow Python Library provides convenient access to the Webflow Data API from applications written in Python. It includes type definitions for all request and response fields, and offers both synchronous and asynchronous clients powered by `httpx`. The library is actively maintained, with regular updates through Fern regeneration, and is currently at version 2.0.0.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the synchronous Webflow client using an API access token and demonstrates fetching a list of sites. For asynchronous operations, use `AsyncWebflow` and `await` calls.

import os
from webflow.client import Webflow

# It's recommended to store your API token securely, e.g., in an environment variable
WEBFLOW_ACCESS_TOKEN = os.environ.get('WEBFLOW_ACCESS_TOKEN', 'YOUR_WEBFLOW_ACCESS_TOKEN')

if not WEBFLOW_ACCESS_TOKEN or WEBFLOW_ACCESS_TOKEN == 'YOUR_WEBFLOW_ACCESS_TOKEN':
    print("Warning: Please set the WEBFLOW_ACCESS_TOKEN environment variable or replace 'YOUR_WEBFLOW_ACCESS_TOKEN' with your actual token.")
else:
    try:
        client = Webflow(access_token=WEBFLOW_ACCESS_TOKEN)
        # Example: List all sites
        sites_response = client.sites.list()
        if sites_response.sites:
            print(f"Found {len(sites_response.sites)} site(s):")
            for site in sites_response.sites:
                print(f"- Site Name: {site.display_name}, ID: {site.id}")
        else:
            print("No sites found or token lacks sufficient permissions.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →