Python quickstart
Get started with the Lightfield API using Python.
This guide walks you through making your first request to the Lightfield API using the official Python SDK.
Installation
Section titled “Installation”Install the library from PyPI:
pip install lightfieldGet an API key
Section titled “Get an API key”An API key can be created in Lightfield settings (admin only).
When creating the key, select the scopes your integration needs.
For the example below, you’ll need accounts:read.
Make your first request
Section titled “Make your first request”Create a client and list one account to verify your key and scope.
1. Create a new file (e.g. quickstart.py) and paste in:
from lightfield import Lightfield
client = Lightfield( api_key="My API Key",)
# list one accountaccounts = client.account.list(limit=1)print(accounts)2. Replace "My API Key" with your actual API key (sk_lf_...).
3. Run the script from your terminal (from the same directory as the file):
python quickstart.pyThe client returns an AccountListResponse object. A successful response looks like:
AccountListResponse( data=[ Data( id="id", created_at="created_at", fields={ "foo": DataFields(value="string", value_type="value_type"), }, http_link="http_link", relationships={ "foo": DataRelationships( cardinality="cardinality", object_type="object_type", values=["string"], ), }, ) ], object="list", total_count=1,)With limit=1 you get at most one account. To fetch more results, use limit and offset — see List methods for pagination. The full API is in the Python API Reference.
Error handling: The SDK raises typed exceptions you can catch. If your API key is wrong you’ll see:
lightfield.AuthenticationError: Error code: 401 - {'error': {'type': 'unauthorized', 'message': 'Invalid API key.'}}If the key is valid but missing the required scope:
lightfield.PermissionDeniedError: Error code: 403 - {'error': {'type': 'forbidden', 'message': "Token does not have the 'accounts:read' scope."}}For more on error responses and how to handle them, see Errors.
Next steps
Section titled “Next steps”- Objects in Lightfield — Overview of object types (accounts, contacts, opportunities, and more) and how they relate.
- Python API Reference — Full API reference with Python code examples.
- Rate limits — Request limits and how to handle 429 responses.
- Idempotency — Safe retries for create and update operations.