Developer sign-in required
The Developer & Integration section is restricted to signed-in developer accounts. Sign in with your AI2N.ai developer credentials to continue.
Code Samples: Listing Courses
Watch: Code Samples: Listing Courses walkthrough (placeholder — video not yet recorded)
This page is a complete, runnable-shaped example of an authenticated GET request against the courses endpoint. It shows the same call in TypeScript, C#, Python and curl, each one passing a bearer token in the Authorization header and handling a non-2xx response by reading the problem-details error and its correlation ID. Once a sandbox environment is available, you can swap in a real access token from the Authentication page and try any of these directly. And one habit worth building early: the access token is always read from an environment variable in every example here -- never hardcode a literal token anywhere in your source code.
This selector is illustrative — there is no live public API to switch against yet. All requests/responses below use non-production example data.
API version: v1 · Status: Illustrative — pre-release
A complete, runnable-shaped example of an authenticated GET request. Swap in a real access token from Authentication to try it against a sandbox once one is available.
const res = await fetch("https://api.ai2n.ai/v1/courses?limit=25", {
headers: { Authorization: `Bearer ${process.env.AI2N_ACCESS_TOKEN}` },
});
if (!res.ok) {
const problem = await res.json();
throw new Error(`${problem.title} (correlation: ${problem.correlationId})`);
}
const { data: courses, nextCursor } = await res.json();
console.log(courses.map((c) => c.title));
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("AI2N_ACCESS_TOKEN"));
var resp = await client.GetAsync("https://api.ai2n.ai/v1/courses?limit=25");
resp.EnsureSuccessStatusCode();
var json = await resp.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<CourseListResponse>(json);
import os, requests
resp = requests.get(
"https://api.ai2n.ai/v1/courses",
params={"limit": 25},
headers={"Authorization": f"Bearer {os.environ['AI2N_ACCESS_TOKEN']}"},
)
resp.raise_for_status()
courses = resp.json()["data"]
print([c["title"] for c in courses])
curl "https://api.ai2n.ai/v1/courses?limit=25" \ -H "Authorization: Bearer $AI2N_ACCESS_TOKEN" \ -H "Accept: application/json"
🔒 AI2N_ACCESS_TOKEN is read from the environment in every example — never a literal token in source.