API Cookbook — Basic Recipes

Prerequisites

  • API username and key (set by a Level 3 admin — see User Management)
  • Collection reference (r param) — visible in the URL when viewing the collection
  • View ID (g param) — get it from f=meta

Recipe 1 — Discover a Collection

curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=7mFzPkZUqYJW3QW&g=7&f=meta"

The meta response gives you everything: field names and types, all views and their IDs, all actions and their IDs, and template strings for every common operation.

Recipe 2 — List All Records

curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=VIEWID&f=crosslist&per_page=50&page=1"

Omit dxField/dxValue to get all records visible to the view. Paginate with page and per_page.

Recipe 3 — Filter by Field Value

# Get all records where Status = "Open"
curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=VIEWID&f=crosslist&dxField=strD5_1_6&dxValue=Bug"

dxField must be a column name from the schema (get it from meta or describe).

Recipe 4 — Read a Single Record

curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=VIEWID&f=readone&dxId=1234"

Recipe 5 — Create a Record

curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=WRITEVIEWID&f=create" \
  -d "strD5_1_1=My+New+Item&strD5_1_6=Bug&notes=Created+via+API"

The view must have write (API_Type = Write) permission. The write action is configured on the view.

Response: {“fnerr”:0,“dxid”:1235} — the new record's ID.

Recipe 6 — Update a Record

# Partial update — only named fields are changed
curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=WRITEVIEWID&f=update&dxId=1234" \
  -d "strD5_1_5=True&notes=Marked+complete+via+API"

Omitted fields are left unchanged.

Recipe 7 — Get Audit Trail

curl -s -k -X POST "https://wherewelearn.com/api/apic.php" \
  -d "u=myuser&k=mykey&r=COLLREF&g=VIEWID&f=interactionlist&dxId=1234"

Returns every action ever taken on the record: timestamp, actor, action name, notes.

PHP Example

function least_api(string $fn, array $params, string $ref, string $gid): array {
    $base = ['u'=>'APIUSER','k'=>'APIKEY','r'=>$ref,'g'=>$gid,'f'=>$fn];
    $ch = curl_init('https://wherewelearn.com/api/apic.php');
    curl_setopt_array($ch,[
        CURLOPT_POST=>true,
        CURLOPT_POSTFIELDS=>http_build_query(array_merge($base,$params)),
        CURLOPT_RETURNTRANSFER=>true,
        CURLOPT_SSL_VERIFYPEER=>false,
    ]);
    $result = json_decode(curl_exec($ch),true);
    curl_close($ch);
    return $result;
}
 
// Usage
$meta    = least_api('meta',   [], '7mFzPkZUqYJW3QW', '7');
$records = least_api('crosslist',['per_page'=>20], '7mFzPkZUqYJW3QW', '8');
$new_id  = least_api('create', ['strD5_1_1'=>'Test item','strD5_1_6'=>'Development'], '7mFzPkZUqYJW3QW', '8')['data']['dxid'];