Skip to content

Instantly share code, notes, and snippets.

@ochilab
Last active August 26, 2025 03:57
Show Gist options
  • Select an option

  • Save ochilab/9b9bfe95f75d69b3e7b6481930e48a6f to your computer and use it in GitHub Desktop.

Select an option

Save ochilab/9b9bfe95f75d69b3e7b6481930e48a6f to your computer and use it in GitHub Desktop.
xapiでステートメントを取得する(Learning Locker)
import requests, json, urllib.parse as ul
# === 事前設定 ===
ENDPOINT = "https://<your-ll-host>/data/xAPI/" # 末尾は /data/xAPI/
KEY = "<LL_CLIENT_KEY>"
SECRET = "<LL_CLIENT_SECRET>"
#ここのパラメータを変えることで検索条件を指定できる
params = {
"limit": 10,
# "agent": json.dumps({"mbox": "mailto:[email protected]"}), # 例:特定Agentで絞込
#"verb": "http://adlnet.gov/expapi/verbs/answered",
# "activity": "https://example.org/quiz/1",
}
q = ul.urlencode(params)
resp = requests.get(
ENDPOINT + f"statements?{q}",
auth=(KEY, SECRET),
headers={"X-Experience-API-Version": "1.0.3"},
timeout=15
)
data = resp.json()
print(len(data.get("statements", [])))
for stmt in data.get("statements", []):
print(stmt)
# 続きがある場合は "more" の相対URLが返るので、ENDPOINT と連結して再GET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment