Quick start¶
This page takes you from API credentials to your first successful call. It uses LucidSource. LucidRetail uses the same credentials flow with its own host, but its own API version and endpoints; see LucidRetail Getting Started.
1. Get your credentials¶
You call the API with an OAuth2 client ID and client secret. A company administrator creates them in the product’s web console: on the API Keys page of LucidSource for a company, or of LucidRetail for a dispensary location. See Credentials for the steps. Keep the secret on your server; never ship it in a browser or mobile app.
Before you start, open a ticket at help.lucidgreen.io to make sure API access is turned on for your company.
Product |
Production host |
|---|---|
LucidSource |
|
LucidRetail |
|
Build and test your integration against the test environment first. A company administrator creates its credentials in the test host’s web console, with the test account Lucid Green sets up during integration setup. They don’t work in production:
Product |
Test host |
|---|---|
LucidSource |
|
LucidRetail |
|
2. Request an access token¶
Exchange the client ID and secret for an access token with the OAuth2 client credentials grant:
curl -X POST https://source.lucidgreen.io/o/token/ \
-d grant_type=client_credentials \
-d client_id="$CLIENT_ID" \
-d client_secret="$CLIENT_SECRET"
import os
import requests
response = requests.post(
"https://source.lucidgreen.io/o/token/",
data={
"grant_type": "client_credentials",
"client_id": os.environ["CLIENT_ID"],
"client_secret": os.environ["CLIENT_SECRET"],
},
timeout=30,
)
response.raise_for_status()
access_token = response.json()["access_token"]
The response contains the token and how many seconds it is valid for:
{
"access_token": "q8Vb3kTzR1mN6yXcLp0sWd4hJf7gAe",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "read write"
}
Reuse the token for every call until it expires. See Authentication for details.
3. Make your first call¶
Send the token in the Authorization header. This call lists the brands your credentials can access:
# ACCESS_TOKEN is the access_token value from step 2's response
curl https://source.lucidgreen.io/api/v1.5/brands/ \
-H "Authorization: Bearer $ACCESS_TOKEN"
response = requests.get(
"https://source.lucidgreen.io/api/v1.5/brands/",
headers={"Authorization": f"Bearer {access_token}"},
timeout=30,
)
response.raise_for_status()
for brand in response.json():
print(brand["uuid"], brand["name"], brand["state"])
[
{
"uuid": "37mP2qR7vLwN4tYhB3cJdX",
"name": "Green Valley Farms",
"state": "CA"
}
]
4. Page through lists¶
Product, batch and asset lists are paginated. Follow the next URL until it is null:
url = "https://source.lucidgreen.io/api/v1.5/products/?page_size=500"
products = []
while url:
response = requests.get(url, headers={"Authorization": f"Bearer {access_token}"}, timeout=30)
response.raise_for_status()
page = response.json()
products.extend(page["results"])
url = page["next"]
See Paginated lists.
Next steps¶
Read the Conventions for IDs, dates and headers, and Responses for status codes and errors.
Learn how LucidIDs, CaseIDs and Collections fit together.
Browse the LucidSource or LucidRetail API reference.