--- title: Python quickstart | Lightfield description: Get started with the Lightfield API using Python. --- The Lightfield API is currently in beta. Methods, parameters, and response schemas may change as we incorporate feedback during this period. This guide walks you through making your first request to the Lightfield API using the official Python SDK. ## Installation Install the library from PyPI: Terminal window ``` pip install lightfield ``` ## Get an API key An [API key](/using-the-api/api-keys/index.md) can be created in [Lightfield settings](https://crm.lightfield.app/crm/settings/api-keys) (admin only). When creating the key, select the [scopes](/using-the-api/scopes/index.md) your integration needs. For the example below, you’ll need `accounts:read`. ## Make your first request Create a client and [list](/api/resources/account/methods/list/index.md) 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 account accounts = 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): Terminal window ``` python quickstart.py ``` The 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](/using-the-api/list-endpoints/index.md) for pagination. The full API is in the [Python API Reference](/api/python/index.md). **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](/using-the-api/errors/index.md). ## Next steps - **[Objects in Lightfield](/objects-in-lightfield/object-types/index.md)** — Overview of object types (accounts, contacts, opportunities, and more) and how they relate. - **[Python API Reference](/api/python/index.md)** — Full API reference with Python code examples. - **[Rate limits](/using-the-api/rate-limits/index.md)** — Request limits and how to handle 429 responses. - **[Idempotency](/using-the-api/idempotency/index.md)** — Safe retries for create and update operations.