API access

Grab ready-made request examples for every collection in this workspace.

Example: record operations

Pick a collection to generate code examples for reading and updating:

// JavaScript example: reading records
// Filterable fields: locale, total_score, streak_days, last_active_at, modules_done
async function fetchMemberActivityRecords() {
    const response = await fetch(`https://api.phalarope.dev/v1/workspaces/7f30adbc4192/collections/MemberActivity`, {
        headers: {
            'api_key': 'ph_live_4c1e8a7f26b93d05e7ab41f0c9d2', // or use await Session.me() to read the key
            'Content-Type': 'application/json'
        }
    });
    const data = await response.json();
    console.log(data);
}

// JavaScript example: updating a record
// Filterable fields: locale, total_score, streak_days, last_active_at, modules_done
async function updateMemberActivityRecord(recordId, updateData) {
    const response = await fetch(`https://api.phalarope.dev/v1/workspaces/7f30adbc4192/collections/MemberActivity/${recordId}`, {
        method: 'PUT',
        headers: {
            'api_key': 'ph_live_4c1e8a7f26b93d05e7ab41f0c9d2', // or use await Session.me() to read the key
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(updateData)
    });
    if (!response.ok) {
        throw new Error(`Update failed with status ${response.status}`);
    }
    return await response.json();
}