Legit API Client

raw JSON →
1.1.4785 verified Sat May 09 auth: no python

The official Python client for the Legit inventory management API. Provides ORM-like models and a client for managing assets, locations, custom fields, and more. Actively maintained with frequent releases.

pip install legit-api-client
error AttributeError: module 'legit_api_client' has no attribute 'Client'
cause Using wrong import path: 'import legit_api_client' and then 'legit_api_client.Client' works, but some try to import from submodule incorrectly.
fix
Use 'from legit_api_client import Client'
error TypeError: Client() got an unexpected keyword argument 'token'
cause Old API used 'token' parameter; current version uses 'api_key'.
fix
Use 'Client(api_key="...")' instead of 'Client(token="...")'
error StopIteration: generator raised StopIteration
cause Trying to get next() on a generator that has been exhausted or empty.
fix
Use for loop or list() to consume the generator, e.g., for asset in client.assets.list():
breaking In version 1.0, the Client constructor changed from requiring a 'token' parameter to 'api_key'.
fix Use 'api_key' instead of 'token'.
gotcha All list methods return a Generator, not a list. You must iterate or convert to list explicitly.
fix Wrap with list() if you need a list: list(client.assets.list())
deprecated The method 'client.assets.get()' is deprecated in favor of 'client.assets.retrieve()'.
fix Use client.assets.retrieve(id) instead of client.assets.get(id).

Initialize with an API key and fetch a list of assets.

from legit_api_client import Client

client = Client(api_key=os.environ.get('LEGIT_API_KEY', ''))
assets = client.assets.list()
print(assets)