Package: webflow
Webflow Python LibraryThe Webflow Python Library provides convenient access to theWebflow Data APIfrom
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.DocumentationExplore the API reference documentationhere.InstallationAdd this dependency to your project's build file:pipinstallwebflow# orpoetryaddwebflowUsageSimply importWebflowand start making calls to our API.fromwebflow.clientimportWebflowclient=Webflow(access_token="YOUR_ACCESS_TOKEN")site=client.sites.get("site-id")Async ClientThe SDK also exports an async client so that you can make non-blocking
calls to our API.fromwebflow.clientimportAsyncWebflowclient=AsyncWebflow(access_token="YOUR_ACCESS_TOKEN")asyncdefmain()->None:site=awaitclient.sites.get("site-id")print("Received site",site)asyncio.run(main())OAuthTo implement OAuth, you'll need toregister a Webflow App in your WorkspaceStep 1: Authorize URLThe first step in OAuth is to generate an Authorization URL. Use this URL
to fetch your Authorization Code. See thedocsfor more details.fromwebflow.oauthimportauthorize_urlfromwebflowimportOauthScopeurl=authorize_url(client_id="YOUR_CLIENT_ID",scope=OauthScope.USERS_READ,# or [OauthScope.USERS_READ, OauthScope.USERS_WRITE]state="1234567890",# optionalredirect_uri="https://my.server.com/oauth/callback",# optional)print(url)Step 2: Retrieve your acccess tokenUse theget_access_tokenfunction and pass in yourclient_id,client_secret, andauthorization_code.fromwebflow.oauthimportget_access_tokenaccess_token=get_access_token(client_id="YOUR_CLIENT_ID",client_secret="YOUR_CLIENT_SECRET",code="YOUR_AUTHORIZATION_CODE")Step 3: Instantiate the clientInstantiate the client using youraccess_token.fromwebflow.clientimportWebflowclient=Webflow(access_token=access_token)Webflow ModuleAll of the models are nested within the Webflow module. Let IntelliSense
guide you!Exception HandlingAll errors thrown by the SDK will be subclasses ofApiError.importwebflowtry:client.sites.get(...)exceptwebflow.core.ApiErrorase:# Handle all errorsprint(e.status_code)print(e.body)exceptwebflow.BadRequestErrorase:# Handle specific errorprint(e.status_code)print(e.body)AdvancedTimeoutsBy default, requests time out after 60 seconds. You can configure this with a
timeout option, which accepts a float.fromwebflow.clientimportWebflowclient=Webflow(# 20 secondstimeout=20.0,)Custom HTTP clientYou can override the httpx client to customize it for your use-case. Some common use-cases
include support for proxies and transports.importhttpxfromwebflow.clientimportWebflowclient=Webflow(http_client=httpx.Client(proxies="http://my.test.proxy.example.com",transport=httpx.HTTPTransport(local_address="0.0.0.0"),),)Beta StatusThis SDK is inPreview, and there may be breaking changes between versions without a major
version update.To ensure a reproducible environment (and minimize risk of breaking changes), we recommend pinning a specific package version.ContributingWhile 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!