Cloud Foundry Python Client
raw JSON → 1.40.3 verified Mon Apr 27 auth: no python
A client library for interacting with Cloud Foundry APIs. Current version 1.40.3 (released 2025-03-10), supports Python >=3.10. Maintained by the Cloud Foundry community with regular releases.
pip install cloudfoundry-client Common errors
error ImportError: cannot import name 'CloudFoundryClient' from 'cloudfoundry_client' ↓
cause Incorrect import path; CloudFoundryClient is not at top-level.
fix
Use: from cloudfoundry_client.client import CloudFoundryClient
error AttributeError: 'NoneType' object has no attribute 'list' ↓
cause Forgot to call client.init() before making API calls.
fix
Call client.init() after creating the client object.
error requests.exceptions.HTTPError: 403 Client Error: Forbidden ↓
cause OAuth token missing or insufficient permissions.
fix
Ensure client_id and client_secret are correct and the client has the required scopes.
Warnings
breaking In v1.24.0, the client initialization changed from positional arguments to keyword-only for OAuth parameters. Old code using positional arguments will break. ↓
fix Use keyword arguments: CloudFoundryClient(endpoint, client_id=..., client_secret=..., ...)
gotcha The client does not automatically refresh tokens; you must call client.init() or use a refresh_token. ↓
fix Always call client.init() after instantiation, or pass a refresh_token to enable automatic refresh.
deprecated V1 API resources (e.g., cloudfoundry_client.v1) are deprecated and will be removed in a future version. ↓
fix Migrate to V2 or V3 resources, e.g., from cloudfoundry_client.v2 import ...
Imports
- CloudFoundryClient
from cloudfoundry_client.client import CloudFoundryClient - Organization
from cloudfoundry_client.v2.organizations import Organization
Quickstart
from cloudfoundry_client.client import CloudFoundryClient
api_endpoint = 'https://api.cf.example.com'
client_id = os.environ.get('CF_CLIENT_ID', '')
client_secret = os.environ.get('CF_CLIENT_SECRET', '')
client = CloudFoundryClient(api_endpoint, client_id=client_id, client_secret=client_secret)
client.init()
orgs = client.organizations.list()
for org in orgs:
print(org['entity']['name'])