Drive Search Console Report from your own code
The page is the core tool: it reads a Google Search Console Performance export in the browser, draws the annotated
chart, finds the dated changes and the queries worth working on, all free. Its optional AI step is also
available over HTTP. You send one JSON object whose values are all strings; the simplest way to build it exactly as the
page does is the page's own code, which also runs under Node:
GSC.buildInput({question}, GSC.analyze(GSC.readFiles([{name, text}]), {notes, brands})) in gsc.js,
and recon.js re-checks a reply.
Base URL: https://api.skillsafe.ai/v1/app-api. Every call sends
Content-Type: application/json and, once you have a token,
Authorization: Bearer <token>. The step runs on llm-default with a 10% publisher
markup. A run needs a signed-in (user) token and is metered: the platform holds the estimate's
hold_credits while the run is in flight and then charges only what it used
(charged_credits). /estimate is free. A plain-text summary is at /llms.txt.
The response envelope
Every response is {"data": ..., "error": null} on success or {"data": null, "error": {"code", "message"}} on failure.
Error codes
| HTTP | code | meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | The body is not a JSON object, or a field is the wrong type. Every field of the run input is a string. |
| 401 | UNAUTHORIZED | No token, or an expired one: get a new one (step 2). |
| 402 | INSUFFICIENT_CREDITS | The balance is below the run's minimum. Top up at skillsafe.ai/account/billing/. |
| 403 | FORBIDDEN | A guest token tried a metered run: sign in for a personal token. |
| 404 | NOT_FOUND | Unknown job id. |
| 429 | RATE_LIMITED | Back off and retry with the same Idempotency-Key. |
The task field
There is one task. Send it first.
| task | what it returns |
|---|---|
"read" | Explains every dated change the page found (its date, direction, the leads that fit, how to tell them apart) and picks two to six of the queries worth working on, each with one action; a query with a low click-through rate for its position gets a new title and meta description. A missing or unknown task is answered as read and named as the first entry of gaps. |
Input fields
| field | what | |
|---|---|---|
task | required | "read". |
series | optional | Weekly totals: header week_from | days | clicks | impressions | ctr | position, one line per week (Monday start), at most the last 70 weeks. Empty when the export has no Dates file. |
facts | required | JSON string: site, from, to, days, totals, comparison (the last 28 days against the 28 before, or the two halves of a shorter range, with change), events[] - {id, kind, date, direction, before_per_day, after_per_day, change_pct, text} with kind step, spike or dip - weekday_rhythm, devices[], countries[] and checks[] - {id, level, kind, text}. |
opportunities | optional | The queries worth working on: id | query | clicks | impressions | ctr | position | type | about_extra_clicks, type one of low_ctr, near_top, page_two; at most 25. |
top_queries | optional | The 15 queries with the most clicks: query | clicks | impressions | ctr | position. |
top_pages | optional | The 10 pages with the most clicks, same columns. |
notes | optional | Dated notes, one per line: [N1] 2026-08-19: .... |
question | optional | Up to 400 characters. |
clip_note | optional | What was left out of the run. |
How the page finds a dated change: a step is a day where the median of the next 14 days (7 for ranges under 12 weeks) differs from the median of the 14 before by 20% or more; the largest win, 14 days apart, at most four. A spike or dip is a day 2.5 times above, or under 40% of, the median of the same weekday in the three weeks either side. A query is low_ctr at positions under 8 when its click-through rate is under half the usual rate at its position (this site's own median where five or more queries sit there, else a typical curve), near_top at positions 3.5 to 8, page_two at 8 to 20, with impressions at least the 60th percentile and never under 20.
The reply
One JSON object, first key task, every key present, an empty array where there is nothing to say: headline; summary; changes[] - {ref, date, direction, reading, notes[], causes[], check}, one per event; actions[] - {ref, query, action, why, title, description} with action one of rewrite_snippet, improve_content, add_internal_links, match_intent, new_page, technical_check (only rewrite_snippet carries a title of at most 60 characters and a description of at most 155); next_steps[]; gaps[].
What the page checks
Over HTTP you receive the model's reply as-is. The page checks that every change it explains is one the page found, with the same date and direction; that every change found is explained; that every note id exists; that every query named is in the export under the id the page gave it; that new titles and descriptions fit what Google shows; and that no figure in the prose is one the page did not send. Load recon.js to run the same checks.
Worked example: a recipe blog after a drop
The input the page builds for its recipe-blog example (213 days, a core update noted on 2026-08-19, a rewrite on 2026-09-02):
{
"task": "read",
"series": "week_from | days | clicks | impressions | ctr | position\n2026-03-30 | 5 | 2164 | 49018 | 4.41% | 7.8\n2026-04-06 | 7 | 2783 | 64666 | 4.3% | 7.8\n2026-04-13 | 7 | 2869 | 67658 | 4.24% | 7.9\n2026-04-20 | 7 | 2955 | 67584 | 4.37% | 7.9\n2026-04-27 | 7 | 2977 | 70077 | 4.25% | 8\n2026-05-04 | 7 | 3002 | 70717 | 4.25% | 8\n2026-05-11 | 7 | 2987 | 68792 | 4.34% | 8\n2026-05-18 | 7 | 3051 | 71584 | 4.26% | 7.9\n2026-05-25 | 7 | 3161 | 74495 | 4.24% | 7.8\n2026-06-01 | 7 | 3238 | 75334 | 4.3% | 8\n2026-06-08 | 7 | 3267 | 77259 | 4.23% | 7.9\n2026-06-15 | 7 | 3289 | 76031 | 4.33% | 7.8\n2026-06-22 | 7 | 3201 | 73318 | 4.37% | 8\n2026-06-29 | 7 | 3188 | 75295 | 4.23% | 7.8\n2026-07-06 | 7 | 3277 | 76391 | 4.29% | 7.9\n2026-07-13 | 7 | 3253 | 74390 | 4.37% | 7.9\n2026-07-20 | 7 | 3434 | 79700 | 4.31% | 7.8\n2026-07-27 | 7 | 3473 | 80598 | 4.31% | 7.9\n2026-08-03 | 7 | 3460 | 78599 | 4.4% | 7.9\n2026-08-10 | 7 | 3421 | 79540 | 4.3% | 7.9\n2026-08-17 | 7 | 2429 | 68889 | 3.53% | 9.9\n2026-08-24 | 7 | 2152 | 69336 | 3.1% | 10.6\n2026-08-31 | 7 | 2173 | 70091 | 3.1% | 10.4\n2026-09-07 | 7 | 2167 | 71618 | 3.03% | 10.6\n2026-09-14 | 7 | 2243 | 72000 | 3.12% | 10.7\n2026-09-21 | 7 | 2209 | 71928 | 3.07% | 10.5\n2026-09-28 | 7 | 2227 | 72968 | 3.05% | 10.7\n2026-10-05 | 7 | 2231 | 72554 | 3.07% | 10.6\n2026-10-12 | 7 | 2223 | 72332 | 3.07% | 10.6\n2026-10-19 | 7 | 2260 | 74404 | 3.04% | 10.7\n2026-10-26 | 5 | 1567 | 51871 | 3.02% | 10.8",
"facts": "{\"site\":\"panandplate.example\",\"from\":\"2026-04-01\",\"to\":\"2026-10-30\",\"days\":213,\"totals\":{\"clicks\":86331,\"impressions\":2219037,\"ctr\":\"3.89%\",\"position\":8.8},\"comparison\":{\"window\":\"last 28 days vs the 28 before\",\"current\":{\"from\":\"2026-10-03\",\"to\":\"2026-10-30\",\"clicks\":8989,\"impressions\":293996,\"ctr\":\"3.06%\",\"position\":10.6},\"previous\":{\"from\":\"2026-09-05\",\"to\":\"2026-10-02\",\"clicks\":8827,\"impressions\":287805,\"ctr\":\"3.07%\",\"position\":10.6},\"change\":{\"clicks\":\"1.8%\",\"impressions\":\"2.2%\",\"ctr_points\":-0.01,\"position\":0}},\"events\":[{\"id\":\"E1\",\"kind\":\"step\",\"date\":\"2026-08-19\",\"direction\":\"down\",\"before_per_day\":473.5,\"after_per_day\":296.5,\"change_pct\":-37.4,\"text\":\"From 2026-08-19 a typical day's clicks fell from 473.5 to 296.5 (-37.4%), the median of the 14 days before against the 14 days from that date.\"}],\"weekday_rhythm\":{\"weekend\":478,\"weekday\":376.8,\"ratio\":1.27},\"devices\":[{\"device\":\"MOBILE\",\"clicks\":10234,\"impressions\":520000,\"ctr\":\"1.97%\",\"position\":8.6},{\"device\":\"DESKTOP\",\"clicks\":4896,\"impressions\":160000,\"ctr\":\"3.06%\",\"position\":7.9},{\"device\":\"TABLET\",\"clicks\":463,\"impressions\":21000,\"ctr\":\"2.2%\",\"position\":9.1}],\"countries\":[{\"country\":\"United States\",\"clicks\":7995,\"impressions\":360000},{\"country\":\"United Kingdom\",\"clicks\":5791,\"impressions\":140000},{\"country\":\"Canada\",\"clicks\":1750,\"impressions\":70000},{\"country\":\"Australia\",\"clicks\":1323,\"impressions\":52000},{\"country\":\"India\",\"clicks\":379,\"impressions\":45000}],\"checks\":[{\"id\":\"D1\",\"level\":\"note\",\"kind\":\"filters\",\"text\":\"The export was filtered: Search type: Web; Date: Custom.\"},{\"id\":\"D2\",\"level\":\"note\",\"kind\":\"anonymized\",\"text\":\"The listed queries account for 57% of all clicks. Google leaves rare queries out of the export for privacy, so query totals are lower than the chart's.\"},{\"id\":\"D3\",\"level\":\"note\",\"kind\":\"curve\",\"text\":\"This site has too few queries at each position to measure its own click-through curve, so a typical curve is used.\"}]}",
"opportunities": "id | query | clicks | impressions | ctr | position | type | about_extra_clicks\nQ1 | air fryer chicken thighs | 2380 | 135200 | 1.76% | 4.2 | low_ctr | 8436\nQ2 | easy banana bread | 3526 | 98800 | 3.57% | 6.8 | near_top | 7342\nQ3 | sourdough discard pancakes | 2226 | 106600 | 2.09% | 9.4 | page_two | 4170\nQ4 | one pot pasta | 656 | 79300 | 0.83% | 12.6 | page_two | 4102\nQ5 | no knead bread | 1650 | 43940 | 3.76% | 7.4 | near_top | 3183\nQ6 | chicken tikka masala recipe | 457 | 47320 | 0.97% | 15.3 | page_two | 2382\nQ7 | overnight oats ratio | 983 | 54600 | 1.8% | 5.2 | low_ctr | 2293\nQ8 | vegan chili | 1437 | 59280 | 2.42% | 8.7 | page_two | 2120\nQ9 | shakshuka | 385 | 36660 | 1.05% | 11.8 | page_two | 1815\nQ10 | lemon drizzle cake | 2065 | 32760 | 6.3% | 4.8 | near_top | 1539",
"top_queries": "query | clicks | impressions | ctr | position\nhow long to boil eggs | 9793 | 51480 | 19.02% | 2.2\ncrispy roast potatoes | 6620 | 71240 | 9.29% | 3.1\npan and plate | 5986 | 17940 | 33.37% | 1.1\neasy banana bread | 3526 | 98800 | 3.57% | 6.8\nair fryer chicken thighs | 2380 | 135200 | 1.76% | 4.2\nsourdough discard pancakes | 2226 | 106600 | 2.09% | 9.4\npan and plate recipes | 2107 | 8060 | 26.14% | 1\nlemon drizzle cake | 2065 | 32760 | 6.3% | 4.8\npancake recipe without milk | 1897 | 22360 | 8.48% | 3.8\nno knead bread | 1650 | 43940 | 3.76% | 7.4\nvegan chili | 1437 | 59280 | 2.42% | 8.7\nmiso soup | 1245 | 25480 | 4.89% | 6.1\ntomato soup from fresh tomatoes | 1094 | 13520 | 8.09% | 4.4\ncaesar dressing | 1091 | 10660 | 10.23% | 3.3\novernight oats ratio | 983 | 54600 | 1.8% | 5.2",
"top_pages": "page | clicks | impressions | ctr | position\nhttps://panandplate.example/guides/boiled-eggs/ | 3648 | 21000 | 17.37% | 2.3\nhttps://panandplate.example/recipes/roast-potatoes/ | 2978 | 29000 | 10.27% | 3.2\nhttps://panandplate.example/ | 2587 | 15000 | 17.25% | 2\nhttps://panandplate.example/guides/overnight-oats/ | 1589 | 23000 | 6.91% | 5\nhttps://panandplate.example/recipes/air-fryer-chicken-thighs/ | 1464 | 61000 | 2.4% | 4.3\nhttps://panandplate.example/recipes/banana-bread/ | 1378 | 42000 | 3.28% | 6.5\nhttps://panandplate.example/recipes/sourdough-discard-pancakes/ | 1052 | 45000 | 2.34% | 9.2\nhttps://panandplate.example/recipes/no-knead-bread/ | 567 | 18000 | 3.15% | 7.1\nhttps://panandplate.example/recipes/vegan-chili/ | 564 | 25000 | 2.26% | 8.5\nhttps://panandplate.example/recipes/one-pot-pasta/ | 356 | 33000 | 1.08% | 12.1",
"notes": "[N1] 2026-08-19: Google core update rolled out\n[N2] 2026-09-02: rewrote 40 recipe intros",
"question": "Why did clicks fall in August, and what should we fix first?",
"clip_note": "the top 15 of 30 queries by clicks and the 10 queries to work on were sent, not every query; the top 10 of 12 pages were sent"
}
A reply produced from the app's own prompt for exactly that input:
{
"task": "read",
"headline": "Clicks fell on 2026-08-19 from 473.5 to 296.5 a day (-37.4%), and the same day a Google core update rolled out (N1), so check that first: your average position slid from about 8 to about 11 at the same time, which points at lost rankings rather than lost demand.",
"summary": "The export covers 2026-04-01 to 2026-10-30. Over the last 28 days clicks were 8989 against 8827 in the 28 before (1.8% more), so the drop has levelled out at the lower height rather than recovered or kept sinking. The week of 2026-08-10 had 3421 clicks at position 7.9, the week of 2026-08-17 had 2429 at position 9.9, and the week of 2026-08-24 had 2152 at position 10.6. The data is sound: the last week is a partial 5-day week and should not be read as a drop, and the listed queries cover 57% of clicks because Google leaves rare queries out.",
"changes": [
{
"ref": "E1",
"date": "2026-08-19",
"direction": "down",
"reading": "A typical day's clicks fell from 473.5 to 296.5 (-37.4%) and stayed there. Impressions eased from 79540 in the week of 2026-08-10 to 68889 in the week of 2026-08-17, CTR went from 4.3% to 3.53%, and average position went from 7.9 to 9.9, so the site was seen less and clicked less.",
"notes": [
"N1"
],
"causes": [
"The Google core update on the same date lines up with N1; it is a lead, not a proven cause.",
"A site change, lost pages or an indexing problem that happened to start the same day.",
"A template change to titles or snippets that cost clicks at the same positions."
],
"check": "In Search Console compare queries and pages for the 14 days before and after 2026-08-19 and see which lost position or clicks. Check the Pages report for lost URLs and the indexing report for new exclusions, and compare devices to see whether mobile or desktop moved more."
}
],
"actions": [
{
"ref": "Q1",
"query": "air fryer chicken thighs",
"action": "rewrite_snippet",
"why": "It is shown the most (135200 impressions) at position 4.2 yet gets only a 1.76% CTR, the largest estimated gain at about 8436 extra clicks, so the result is seen but not chosen.",
"title": "Air Fryer Chicken Thighs: Crispy Skin, Juicy Inside",
"description": "Cook air fryer chicken thighs with crisp skin and juicy meat. See the temperature, the time and the simple steps for bone-in or boneless thighs."
},
{
"ref": "Q2",
"query": "easy banana bread",
"action": "improve_content",
"why": "It sits at position 6.8 with 98800 impressions and a 3.57% CTR, about 7342 extra clicks if it reaches the top three.",
"title": "",
"description": ""
},
{
"ref": "Q3",
"query": "sourdough discard pancakes",
"action": "improve_content",
"why": "At position 9.4 with 106600 impressions and a 2.09% CTR it is just off the first page results, with about 4170 extra clicks to gain.",
"title": "",
"description": ""
},
{
"ref": "Q4",
"query": "one pot pasta",
"action": "improve_content",
"why": "Position 12.6 with 79300 impressions and a 0.83% CTR means it is seen but buried, worth about 4102 extra clicks.",
"title": "",
"description": ""
},
{
"ref": "Q7",
"query": "overnight oats ratio",
"action": "rewrite_snippet",
"why": "It ranks at position 5.2 with 54600 impressions but only a 1.8% CTR, so the result is seen and passed over; about 2293 extra clicks.",
"title": "Overnight Oats Ratio: Oats, Milk and Yogurt Amounts",
"description": "Get the overnight oats ratio right: how much oats, milk and yogurt to use per serving, plus how to adjust it for a thicker or looser texture."
}
],
"next_steps": [
"Compare queries and pages before and after 2026-08-19 in Search Console to see where the lost position came from.",
"Check the Pages and indexing reports for lost or excluded URLs around that date.",
"Rewrite the snippets for air fryer chicken thighs and overnight oats ratio, then watch their CTR.",
"Improve the pages behind easy banana bread, sourdough discard pancakes and one pot pasta to answer the query more completely."
],
"gaps": [
"N2 (2026-09-02, rewrote 40 recipe intros) lines up with no event, so the export shows no step near that date and it is ruled out as a lead for the August drop.",
"The export cannot show which pages or queries the core update touched, which would settle whether this is an update effect.",
"Rare queries are left out of the export, so the query lists cover only part of the daily totals."
]
}
What the page found when it checked that reply: every date, direction and query matches the export. The page's other examples are software docs after a relaunch and a local plumber's year with a one-day spike; load them on the page to replay them free.
Step 1 — a tiny client helper
One function that sends JSON and unwraps the envelope.
BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here" # from https://search-console-report.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}
import json, urllib.request
BASE = "https://api.skillsafe.ai/v1/app-api"
TOKEN = "paste-your-token-here" # from https://search-console-report.skillsafe.ai/tokens.html
def api(method, path, body=None, headers=None):
req = urllib.request.Request(BASE + path, method=method,
data=None if body is None else json.dumps(body).encode(),
headers={"Content-Type": "application/json", **({"Authorization": "Bearer " + TOKEN} if TOKEN else {}), **(headers or {})})
with urllib.request.urlopen(req) as r:
env = json.load(r)
if env.get("error"):
raise RuntimeError(env["error"])
return env["data"]
// search-console-report.mjs -- Node 18+ (global fetch)
const BASE = "https://api.skillsafe.ai/v1/app-api";
let TOKEN = "paste-your-token-here"; // from https://search-console-report.skillsafe.ai/tokens.html
async function api(method, path, body, headers = {}) {
const r = await fetch(BASE + path, { method, headers: { "Content-Type": "application/json",
...(TOKEN ? { Authorization: "Bearer " + TOKEN } : {}), ...headers },
body: body === undefined ? undefined : JSON.stringify(body) });
const env = await r.json();
if (env.error) throw new Error(env.error.code + ": " + env.error.message);
return env.data;
}
package main
import ("bytes"; "encoding/json"; "fmt"; "net/http")
const base = "https://api.skillsafe.ai/v1/app-api"
var token = "paste-your-token-here" // from https://search-console-report.skillsafe.ai/tokens.html
func api(method, path string, body any, headers map[string]string) (map[string]any, error) {
var buf bytes.Buffer
if body != nil { json.NewEncoder(&buf).Encode(body) }
req, _ := http.NewRequest(method, base+path, &buf)
req.Header.Set("Content-Type", "application/json")
if token != "" { req.Header.Set("Authorization", "Bearer "+token) }
for k, v := range headers { req.Header.Set(k, v) }
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
defer res.Body.Close()
var env struct { Data map[string]any; Error map[string]any }
json.NewDecoder(res.Body).Decode(&env)
if env.Error != nil { return nil, fmt.Errorf("%v", env.Error) }
return env.Data, nil
}
// SearchConsoleReport.java -- Java 17+, with com.fasterxml.jackson.core:jackson-databind
import com.fasterxml.jackson.databind.*;
import java.net.URI; import java.net.http.*; import java.util.*;
public class SearchConsoleReport {
static final String BASE = "https://api.skillsafe.ai/v1/app-api";
static String token = "paste-your-token-here"; // from https://search-console-report.skillsafe.ai/tokens.html
static final ObjectMapper M = new ObjectMapper();
static final HttpClient C = HttpClient.newHttpClient();
static JsonNode api(String method, String path, Object body, Map<String, String> headers) throws Exception {
var b = HttpRequest.newBuilder(URI.create(BASE + path)).header("Content-Type", "application/json");
if (!token.isEmpty()) b.header("Authorization", "Bearer " + token);
if (headers != null) headers.forEach(b::header);
b.method(method, body == null ? HttpRequest.BodyPublishers.noBody() : HttpRequest.BodyPublishers.ofString(M.writeValueAsString(body)));
JsonNode env = M.readTree(C.send(b.build(), HttpResponse.BodyHandlers.ofString()).body());
if (env.hasNonNull("error")) throw new RuntimeException(env.get("error").toString());
return env.get("data");
}
}
require "json"
require "net/http"
BASE = "https://api.skillsafe.ai/v1/app-api"
TOKEN = "paste-your-token-here" # from https://search-console-report.skillsafe.ai/tokens.html
def api(method, path, body = nil, headers = {})
uri = URI(BASE + path)
req = Net::HTTPGenericRequest.new(method, !body.nil?, true, uri.request_uri,
{ "Content-Type" => "application/json" }.merge(TOKEN.empty? ? {} : { "Authorization" => "Bearer #{TOKEN}" }).merge(headers))
req.body = JSON.generate(body) unless body.nil?
env = JSON.parse(Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }.body)
raise env["error"].to_s if env["error"]
env["data"]
end
<?php
const BASE = "https://api.skillsafe.ai/v1/app-api";
$TOKEN = "paste-your-token-here"; // from https://search-console-report.skillsafe.ai/tokens.html
function api(string $method, string $path, $body = null, array $headers = []) {
global $TOKEN;
$h = ["Content-Type: application/json"];
if ($TOKEN) $h[] = "Authorization: Bearer $TOKEN";
foreach ($headers as $k => $v) $h[] = "$k: $v";
$ch = curl_init(BASE . $path);
curl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => $h, CURLOPT_RETURNTRANSFER => true]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$env = json_decode(curl_exec($ch), true);
if (!empty($env["error"])) throw new Exception(json_encode($env["error"]));
return $env["data"];
}
// Program.cs -- .NET 6+ console app
using System.Net.Http.Json; using System.Text.Json; using System.Text.Json.Nodes;
static class Api {
public const string Base = "https://api.skillsafe.ai/v1/app-api";
public static string Token = "paste-your-token-here"; // from https://search-console-report.skillsafe.ai/tokens.html
static readonly HttpClient C = new();
public static async Task<JsonNode?> Call(string method, string path, object? body = null, Dictionary<string, string>? headers = null) {
var req = new HttpRequestMessage(new HttpMethod(method), Base + path);
if (Token != "") req.Headers.Add("Authorization", "Bearer " + Token);
if (headers != null) foreach (var h in headers) req.Headers.Add(h.Key, h.Value);
if (body != null) req.Content = JsonContent.Create(body);
var env = JsonNode.Parse(await (await C.SendAsync(req)).Content.ReadAsStringAsync())!;
if (env["error"] is JsonNode e && e.GetValueKind() != JsonValueKind.Null) throw new Exception(e.ToJsonString());
return env["data"];
}
}
Step 2 — a token
A guest token is enough for /me and /estimate. A run is metered, so it needs a personal token: sign in on /tokens.html and copy it from there.
# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"search-console-report"}' | jq -r '.data.token')
# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN = ""
TOKEN = api("POST", "/guest", {"slug": "search-console-report"})["token"]
// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN = "";
TOKEN = (await api("POST", "/guest", { slug: "search-console-report" })).token;
// inside main: a guest token (enough for /me and /estimate); a run needs your personal token
token = ""
g, err := api("POST", "/guest", map[string]string{"slug": "search-console-report"}, nil)
if err != nil { panic(err) }
token = g["token"].(string)
// inside main: a guest token (enough for /me and /estimate); a run needs your personal token
token = "";
token = api("POST", "/guest", Map.of("slug", "search-console-report"), null).get("token").asText();
# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN.replace("")
TOKEN.replace(api("POST", "/guest", { slug: "search-console-report" })["token"])
// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
$TOKEN = "";
$TOKEN = api("POST", "/guest", ["slug" => "search-console-report"])["token"];
// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
Api.Token = "";
Api.Token = (await Api.Call("POST", "/guest", new { slug = "search-console-report" }))!["token"]!.GetValue<string>();
Step 3 — GET /me
Who the token is (subject_type: user or guest) and the credit balance.
api GET /me | jq '.data | {subject_type, credits}'
me = api("GET", "/me")
print(me["subject_type"], me.get("credits"))
const me = await api("GET", "/me");
console.log(me.subject_type, me.credits);
me, _ := api("GET", "/me", nil, nil)
fmt.Println(me["subject_type"], me["credits"])
JsonNode me = api("GET", "/me", null, null);
System.out.println(me.get("subject_type") + " " + me.get("credits"));
me = api("GET", "/me")
puts [me["subject_type"], me["credits"]].inspect
$me = api("GET", "/me");
echo $me["subject_type"], " ", $me["credits"] ?? "", "\n";
var me = await Api.Call("GET", "/me");
Console.WriteLine($"{me!["subject_type"]} {me["credits"]}");
Step 4 — POST /estimate
Free. The body is the run input itself (not wrapped in {"input": ...}). hold_credits is a reservation, not the price; min_credits is what the balance must cover; model reads gpt-6.2-sol and model_alias llm-default.
# input.json: the run input object - {"task": "read", "series": "week_from | days | clicks ...", "facts": "{...}", "opportunities": "id | query ...", "top_queries": "...", "top_pages": "...", "notes": "[N1] ...", "question": "", "clip_note": ""}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}'
inp = json.load(open("input.json")) # {"task": "read", "series": "week_from | days | clicks ...", "facts": "{...}", "opportunities": "id | query ...", "top_queries": "...", "top_pages": "...", "notes": "[N1] ...", "question": "", "clip_note": ""}
est = api("POST", "/estimate", inp)
print(est["hold_credits"], est["min_credits"], est["model"], est.get("warnings"))
import { readFileSync } from "node:fs";
const input = JSON.parse(readFileSync("input.json", "utf8")); // {task, series, facts, opportunities, top_queries, top_pages, notes, question, clip_note}
const est = await api("POST", "/estimate", input);
console.log(est.hold_credits, est.min_credits, est.model, est.warnings);
raw, _ := os.ReadFile("input.json") // add "os" to the imports
var input map[string]any
json.Unmarshal(raw, &input)
est, _ := api("POST", "/estimate", input, nil)
fmt.Println(est["hold_credits"], est["min_credits"], est["model"])
Map<String, Object> input = M.readValue(new java.io.File("input.json"), Map.class);
JsonNode est = api("POST", "/estimate", input, null);
System.out.println(est.get("hold_credits") + " " + est.get("min_credits") + " " + est.get("model"));
input = JSON.parse(File.read("input.json"))
est = api("POST", "/estimate", input)
puts [est["hold_credits"], est["min_credits"], est["model"]].inspect
$input = json_decode(file_get_contents("input.json"), true);
$est = api("POST", "/estimate", $input);
echo $est["hold_credits"], " ", $est["min_credits"], " ", $est["model"], "\n";
var input = JsonNode.Parse(File.ReadAllText("input.json"))!;
var est = await Api.Call("POST", "/estimate", input);
Console.WriteLine($"{est!["hold_credits"]} {est["min_credits"]} {est["model"]}");
Step 5 — POST /run, then poll the job
Send an Idempotency-Key built from the lane and the input: a retry with the same key never bills twice. The page uses search-console-report:<task>:<hash of every field sent>:a<attempt>, so two runs over the same export with a different question or note never share a key. The job's output.output is the reply text; truncated: true means the balance cut it short.
KEY="search-console-report:read:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json # one JSON object, the lane's contract
echo "$J" | jq '.data | {charged_credits, truncated}'
import hashlib, time
key = "search-console-report:" + inp["task"] + ":" + hashlib.sha256(json.dumps(inp).encode()).hexdigest()[:16] + ":a1"
job = api("POST", "/run", inp, {"Idempotency-Key": key})
while True:
j = api("GET", "/jobs/" + job["job_id"])
if j["status"] in ("succeeded", "failed", "cancelled"):
break
time.sleep(2)
reply = json.loads(j["output"]["output"]) # the lane's JSON object
print(j["charged_credits"], j.get("truncated"), reply.get("headline"))
import { createHash } from "node:crypto";
const key = `search-console-report:${input.task}:${createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 16)}:a1`;
const job = await api("POST", "/run", input, { "Idempotency-Key": key });
let j;
do { await new Promise((r) => setTimeout(r, 2000)); j = await api("GET", "/jobs/" + job.job_id); }
while (!["succeeded", "failed", "cancelled"].includes(j.status));
const reply = JSON.parse(j.output.output);
console.log(j.charged_credits, j.truncated, reply.headline);
sum := sha256.Sum256(raw) // add "crypto/sha256", "encoding/hex", "time" to the imports
key := "search-console-report:" + input["task"].(string) + ":" + hex.EncodeToString(sum[:8]) + ":a1"
job, _ := api("POST", "/run", input, map[string]string{"Idempotency-Key": key})
var j map[string]any
for {
time.Sleep(2 * time.Second)
j, _ = api("GET", "/jobs/"+job["job_id"].(string), nil, nil)
if s := j["status"]; s == "succeeded" || s == "failed" || s == "cancelled" { break }
}
fmt.Println(j["charged_credits"], j["truncated"], j["output"].(map[string]any)["output"])
var digest = java.security.MessageDigest.getInstance("SHA-256").digest(M.writeValueAsBytes(input));
String key = "search-console-report:" + input.get("task") + ":" + HexFormat.of().formatHex(digest, 0, 8) + ":a1";
JsonNode job = api("POST", "/run", input, Map.of("Idempotency-Key", key)), j;
do { Thread.sleep(2000); j = api("GET", "/jobs/" + job.get("job_id").asText(), null, null); }
while (!Set.of("succeeded", "failed", "cancelled").contains(j.get("status").asText()));
JsonNode reply = M.readTree(j.get("output").get("output").asText());
System.out.println(j.get("charged_credits") + " " + reply);
require "digest"
key = "search-console-report:#{input["task"]}:#{Digest::SHA256.hexdigest(JSON.generate(input))[0, 16]}:a1"
job = api("POST", "/run", input, { "Idempotency-Key" => key })
j = nil
loop do
sleep 2
j = api("GET", "/jobs/#{job["job_id"]}")
break if %w[succeeded failed cancelled].include?(j["status"])
end
reply = JSON.parse(j["output"]["output"])
puts [j["charged_credits"], j["truncated"], reply["headline"]].inspect
$key = "search-console-report:" . $input["task"] . ":" . substr(hash("sha256", json_encode($input)), 0, 16) . ":a1";
$job = api("POST", "/run", $input, ["Idempotency-Key" => $key]);
do { sleep(2); $j = api("GET", "/jobs/" . $job["job_id"]); }
while (!in_array($j["status"], ["succeeded", "failed", "cancelled"]));
$reply = json_decode($j["output"]["output"], true);
echo $j["charged_credits"], " ", $reply["headline"], "\n";
var digest = System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(input.ToJsonString()));
var key = $"search-console-report:{input["task"]}:{Convert.ToHexString(digest, 0, 8).ToLowerInvariant()}:a1";
var job = await Api.Call("POST", "/run", input, new() { ["Idempotency-Key"] = key });
JsonNode j;
do { await Task.Delay(2000); j = (await Api.Call("GET", "/jobs/" + job!["job_id"]))!; }
while (!new[] { "succeeded", "failed", "cancelled" }.Contains(j["status"]!.GetValue<string>()));
var reply = JsonNode.Parse(j["output"]!["output"]!.GetValue<string>());
Console.WriteLine($"{j["charged_credits"]} {reply}");
Step 6 — POST /run-stream
The same run as Server-Sent Events. read.json is the same kind of input as step 5 ("task": "read", the weekly totals, the page's facts as a JSON string, the queries to work on, the top queries and pages, the numbered notes and the question).
# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: search-console-report:read:$(shasum -a 256 read.json | cut -c1-16):a1" --data @read.json
rin = json.load(open("read.json")) # {"task": "read", "series": "week_from | days | clicks ...", "facts": "{...}", "opportunities": "id | query ...", "top_queries": "...", "top_pages": "...", "notes": "[N1] ...", "question": "", "clip_note": ""}
req = urllib.request.Request(BASE + "/run-stream", method="POST", data=json.dumps(rin).encode(),
headers={"Content-Type": "application/json", "Authorization": "Bearer " + TOKEN,
"Idempotency-Key": "search-console-report:read:" + hashlib.sha256(json.dumps(rin).encode()).hexdigest()[:16] + ":a1"})
with urllib.request.urlopen(req) as r:
for line in r:
line = line.decode().strip()
if line.startswith("data:"):
print(line[5:].strip()[:200])
const rin = JSON.parse(readFileSync("read.json", "utf8"));
const r = await fetch(BASE + "/run-stream", { method: "POST", body: JSON.stringify(rin), headers: {
"Content-Type": "application/json", Authorization: "Bearer " + TOKEN,
"Idempotency-Key": `search-console-report:read:${createHash("sha256").update(JSON.stringify(rin)).digest("hex").slice(0, 16)}:a1` } });
const dec = new TextDecoder();
for await (const chunk of r.body) for (const line of dec.decode(chunk).split("\n"))
if (line.startsWith("data:")) console.log(line.slice(5).trim().slice(0, 200));
rraw, _ := os.ReadFile("read.json") // add "bufio", "strings" to the imports
rs := sha256.Sum256(rraw)
req, _ := http.NewRequest("POST", base+"/run-stream", bytes.NewReader(rraw))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Idempotency-Key", "search-console-report:read:"+hex.EncodeToString(rs[:8])+":a1")
res, _ := http.DefaultClient.Do(req)
sc := bufio.NewScanner(res.Body)
for sc.Scan() { if l := sc.Text(); strings.HasPrefix(l, "data:") { fmt.Println(l[5:]) } }
String rin = java.nio.file.Files.readString(java.nio.file.Path.of("read.json"));
var rd = java.security.MessageDigest.getInstance("SHA-256").digest(rin.getBytes());
var sreq = HttpRequest.newBuilder(URI.create(BASE + "/run-stream")).header("Content-Type", "application/json")
.header("Authorization", "Bearer " + token).header("Idempotency-Key", "search-console-report:read:" + HexFormat.of().formatHex(rd, 0, 8) + ":a1")
.POST(HttpRequest.BodyPublishers.ofString(rin)).build();
C.send(sreq, HttpResponse.BodyHandlers.ofLines()).body().filter(l -> l.startsWith("data:")).forEach(System.out::println);
rin = File.read("read.json")
uri = URI(BASE + "/run-stream")
req = Net::HTTP::Post.new(uri, "Content-Type" => "application/json", "Authorization" => "Bearer #{TOKEN}",
"Idempotency-Key" => "search-console-report:read:#{Digest::SHA256.hexdigest(rin)[0, 16]}:a1")
req.body = rin
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |h|
h.request(req) { |res| res.read_body { |chunk| chunk.each_line { |l| puts l if l.start_with?("data:") } } }
end
$rin = file_get_contents("read.json");
$ch = curl_init(BASE . "/run-stream");
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => $rin, CURLOPT_HTTPHEADER => [
"Content-Type: application/json", "Authorization: Bearer $TOKEN",
"Idempotency-Key: search-console-report:read:" . substr(hash("sha256", $rin), 0, 16) . ":a1"],
CURLOPT_WRITEFUNCTION => function ($ch, $chunk) { foreach (explode("\n", $chunk) as $l) if (str_starts_with($l, "data:")) echo $l, "\n"; return strlen($chunk); }]);
curl_exec($ch);
var rin = File.ReadAllText("read.json");
var rd = System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(rin));
var sreq = new HttpRequestMessage(HttpMethod.Post, Api.Base + "/run-stream") { Content = new StringContent(rin, System.Text.Encoding.UTF8, "application/json") };
sreq.Headers.Add("Authorization", "Bearer " + Api.Token);
sreq.Headers.Add("Idempotency-Key", $"search-console-report:read:{Convert.ToHexString(rd, 0, 8).ToLowerInvariant()}:a1");
using var http = new HttpClient();
using var res = await http.SendAsync(sreq, HttpCompletionOption.ResponseHeadersRead);
using var rdr = new StreamReader(await res.Content.ReadAsStreamAsync());
for (string? l; (l = await rdr.ReadLineAsync()) != null;) if (l.StartsWith("data:")) Console.WriteLine(l);