#Write and read xAPI statements
The Simplest Data LRS supports writing and reading xAPI statements through the standard Statements resource.
Examples below use the Local / self-managed LRS at http://127.0.0.1:8000 with xAPI 2.0.0.
#PUT statement
Use PUT when your client selects the statement ID. statementId must be a UUID. If the statement body includes an id, it must match the query value.
STMT_ID=$(python3 -c 'import uuid; print(uuid.uuid4())')
curl -i -X PUT "http://127.0.0.1:8000/xAPI/statements?statementId=$STMT_ID" \
-H 'Content-Type: application/json' \
-H 'X-Experience-API-Version: 2.0.0' \
--data "{\"id\":\"$STMT_ID\",\"actor\":{\"mbox\":\"mailto:developer@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/experienced\"},\"object\":{\"id\":\"https://example.com/activities/statement-guide\"}}"A new statement returns 204 No Content. Repeating an equivalent PUT is an idempotent no-op with the same response. Different content at an existing ID returns 409 Conflict.
#POST statement
POST accepts one statement object or an array. A single statement with its own body id is valid; statementId is not a POST query parameter.
POST_ID=$(python3 -c 'import uuid; print(uuid.uuid4())')
curl -fsS -X POST http://127.0.0.1:8000/xAPI/statements \
-H 'Content-Type: application/json' \
-H 'X-Experience-API-Version: 2.0.0' \
--data "{\"id\":\"$POST_ID\",\"actor\":{\"mbox\":\"mailto:developer@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/experienced\"},\"object\":{\"id\":\"https://example.com/activities/post-example\"}}"A successful POST returns 200 OK with an array containing the stored statement ID.
#Read statement
curl -fsS "http://127.0.0.1:8000/xAPI/statements?statementId=$STMT_ID" \
-H 'X-Experience-API-Version: 2.0.0' \
-H 'Accept: application/json'A statementId query returns one statement object, not a statement-result wrapper. Do not combine statementId with other filters except the supported format or attachment controls.
#Next steps
- xAPI versions — Understand supported protocol versions and request headers.
- API Reference — Explore the complete Statements resource contract.
