Skip to main content

No project description provided

Project description

Webflow Python Library

fern shield

The Webflow Python Library provides convenient access to the Webflow API from applications written in Python. The library includes type definitions for all request and response fields, and offers both synchronous and asynchronous clients powered by httpx.

Documentation

API reference documentation is available here.

Installation

Add this dependency to your project's build file:

pip install webflow
# or
poetry add webflow

Usage

Simply import Webflow and start making calls to our API.

from webflow.client import Webflow

client = Webflow(
  client_id="YOUR_CLIENT_ID",
  client_secret="YOUR_CLIENT_SECRET",
  code="YOUR_AUTHORIZATION_CODE"
)
site = client.sites.get("site-id")

Async Client

The SDK also exports an async client so that you can make non-blocking calls to our API.

from webflow.client import AsyncWebflow

client = AsyncWebflow(
  client_id="YOUR_CLIENT_ID",
  client_secret="YOUR_CLIENT_SECRET", 
  code="YOUR_AUTHORIZATION_CODE"
)

async def main() -> None:
    site = await client.sites.get("site-id")
    print("Received site", site)

asyncio.run(main())

OAuth

To implement OAuth, you'll need a registred Webflow App.

Step 1: Authorize URL

The first step in OAuth is to generate an authorization url. Use this URL to fetch your authorization code. See the docs for more details.

from webflow.oauth import authorize_url
from webflow import OauthScope

url = webflow.authorize_url({
  client_id = "[CLIENT ID]",
  scope = OauthScope.ReadUsers, # or [OauthScope.ReadUsers, OauthScope.WriteUsers]
  state = "1234567890", # optional
  redirect_uri = "https://my.server.com/oauth/callback", # optional
});

print(url)

Step 2: Instantiate the client

Pass in your client_id, client_secret, authorization_code when instantiating the client. Our SDK handles generating an access token and passing that to every endpoint.

from webflow.client import Webflow

client = Webflow(
  client_id="YOUR_CLIENT_ID",
  client_secret="YOUR_CLIENT_SECRET",
  code="YOUR_AUTHORIZATION_CODE",
  redirect_uri = "https://my.server.com/oauth/callback", # optional
)

If you want to generate an access token yourself, simply import the get_access_token function.

from webflow.oauth import get_access_token

access_token = get_access_token(
  client_id="YOUR_CLIENT_ID", 
  client_secret="YOUR_CLIENT_SECRET", 
  code="YOUR_AUTHORIZATION_CODE"
  )

Webflow Module

All of the models are nested within the Webflow module. Let Intellisense guide you!

Alt text

Exception Handling

All errors thrown by the SDK will be sublcasses of ApiError.

import webflow

try:
  client.sites.get(...)
except webflow.core.ApiError as e: # Handle all errors
  print(e.status_code)
  print(e.body)
except webflow.BadRequestError as e: # Handle specific error
  print(e.status_code)
  print(e.body)

Advanced

Timeouts

By default requests time out after 60 seconds. You can configure this with a timeout option, which accepts a float.

from webflow.client import Webflow

client = Webflow(
    # 20 seconds
    timeout=20.0,
)

Custom HTTP client

You can override the httpx client to customize it for your use case. Some common usecases include support for proxies and transports.

import httpx

from webflow.client import Webflow

client = Webflow(
    http_client=httpx.Client(
        proxies="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Beta Status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version. This way, you can install the same version each time without breaking changes.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webflow-0.1.0b1.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webflow-0.1.0b1-py3-none-any.whl (150.3 kB view details)

Uploaded Python 3

File details

Details for the file webflow-0.1.0b1.tar.gz.

File metadata

  • Download URL: webflow-0.1.0b1.tar.gz
  • Upload date:
  • Size: 54.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1053-azure

File hashes

Hashes for webflow-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 0d1e05991a1255e015540ea2f088adf46e75dea292d5a7c48e211d22a9528339
MD5 8420041a84988c6d2a86517c8ef45324
BLAKE2b-256 6a60e10c1b980fd79635f822820cf29a749813b550e78cbeba9ecad6affb55a6

See more details on using hashes here.

File details

Details for the file webflow-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: webflow-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 150.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1053-azure

File hashes

Hashes for webflow-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 aff15068c417594c4c2c81c3085c6f0b889303c6108dbc45404986f15803e59e
MD5 d7b4ba490403589c32afd75f81203f3a
BLAKE2b-256 ed7fa9097856ba7f47c6af7e3e4f926de6a88f18cb98af5707cfdb2ca5b01e48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page