Use lightning-sdk api when you need an authenticated request to a Lightning
API endpoint that does not have a dedicated CLI command yet. The command uses
your current Lightning credentials and prints the JSON response.
$ pip install lightning-sdk -U
$ lightning login
$ jq --versionList the teamspaces and projects available to the current user:
$ lightning-sdk api /v1/membershipsPrint only teamspace names:
$ lightning-sdk api /v1/memberships | jq -r '.memberships[].name'Print teamspace IDs with their names. Use the ID as PROJECT_ID in
project-scoped raw API calls:
$ lightning-sdk api /v1/memberships | jq -r '.memberships[] | [.projectId, .name] | @tsv'
$ export PROJECT_ID="replace-with-project-id"Use the jobs API when a script needs fields that are not exposed by
lightning job list.
$ lightning-sdk api "/v1/projects/${PROJECT_ID}/jobs" -X GET -F limit=20
$ lightning-sdk api "/v1/projects/${PROJECT_ID}/jobs" -X GET -F limit=20 | jq -r '.jobs[].name'Use the deployments API to inspect deployment payloads directly:
$ lightning-sdk api "/v1/projects/${PROJECT_ID}/deployments" -X GET -F limit=20
$ lightning-sdk api "/v1/projects/${PROJECT_ID}/deployments" -X GET -F limit=20 | jq -r '.deployments[].name'Sandbox endpoints are organization-scoped. Set ORG_ID explicitly, or derive
the first organization owner ID from memberships:
$ export ORG_ID="$(lightning-sdk api /v1/memberships | jq -r '[.memberships[] | select(.ownerType == "organization") | .ownerId][0]')"
$ lightning-sdk api /v1/core/sandboxes -X GET -f "organizationId=${ORG_ID}" -f "projectId=${PROJECT_ID}" -f limit=20
$ lightning-sdk api /v1/core/sandboxes -X GET -f "organizationId=${ORG_ID}" -f "projectId=${PROJECT_ID}" -f limit=20 | jq -r '.sandboxes[] | .name // .id'