Lookalike Domain Generator API
Building and ranking the lookalikes of a domain, the checks, the register-first list and the downloads all run free in the browser and need no API. The API is for the one metered step: send your domain, a suspicious domain that imitates it and what it does, and get back, as JSON, the reports to send and the texts for your customers. The page works out the relation sentence for you and checks every report against your facts.
Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.
The task field
This app has one task. Always send "task": "report".
| task | What it does | Reply |
|---|---|---|
report | Drafts the evidence list, the abuse reports (registrar, host, Google Safe Browsing, and the payment provider and a copyright notice when flagged), a reply for customers caught by the fake site, a notice for your site and a plan, from your facts only. | One JSON object |
Input fields
All values are strings. task, official, suspect, relation and notes are required.
| Field | Meaning |
|---|---|
task | "report" |
official | Your domain, such as northpine.com. |
suspect | The suspicious domain. An international one in its xn-- form, followed by (shows as ...). |
relation | One sentence on how suspect imitates official, such as n0rthpine.com is a lookalike of northpine.com: '0' in place of 'o'. The page writes it for you. |
notes | What you saw on the suspicious site, in your words. The page keeps the start and end of notes over 4,000 characters and marks the cut. |
flags | Comma-separated, or "": payments (it takes payments), copied (it copies your text, logo or images), trademark (you hold a registered trademark). |
The reply
job.output.output is text holding one JSON object (sometimes inside a ```json fence): relation (string), evidence ([{item, how}]), reports ([{channel, to, subject, body}]; channel is registrar, host and safe_browsing always, payment with the payments flag, dmca with the copied flag), support_reply (string), site_notice (string) and plan ([{when, do}], when is today, this week or ongoing). Facts the input lacks come back as placeholders in square brackets, such as [registrar name from WHOIS]. Before sending anything, check that every report names suspect and that no email, IP address or domain appears that you did not give; the page does this and lists what to fix. If the balance ran low, truncated is true and the object may stop early; the page keeps every section that arrived whole.
Worked example
Input (input.json), the northpine.com example on the page:
{
"task": "report",
"official": "northpine.com",
"suspect": "n0rthpine.com",
"relation": "n0rthpine.com is a lookalike of northpine.com: '0' in place of 'o' (look-alike letters, high risk).",
"notes": "Customers forwarded an email with the subject \"Your Northpine order is on hold\" that links to n0rthpine.com/account/verify. That page copies our sign-in page and our logo, then asks for the card number and CVV to \"release the order\". Two customers wrote to support on 2 December saying they were charged 49.99 USD and have no order with us.",
"flags": "payments,copied"
}
Reply:
{
"relation": "n0rthpine.com is a lookalike site that imitates northpine.com by using a zero in place of the letter 'o' in the name. It copies the sign-in page and logo of northpine.com and asks for card details.",
"evidence": [
{
"item": "The forwarded email with the subject \"Your Northpine order is on hold\"",
"how": "Ask the customers to forward it as an attachment (.eml) so the full headers are kept, and save it with the date you received it."
},
{
"item": "The page n0rthpine.com/account/verify, which asks for the card number and CVV to \"release the order\"",
"how": "Take a full-page screenshot showing the address bar and the date and time, and save the full URL."
},
{
"item": "A side-by-side with the real page",
"how": "Place a screenshot of the sign-in page at northpine.com next to a screenshot of n0rthpine.com/account/verify, with the copied logo visible in both."
},
{
"item": "The WHOIS record for n0rthpine.com (registrar and creation date)",
"how": "Search n0rthpine.com at lookup.icann.org and save the result as a PDF or screenshot with the date."
},
{
"item": "The hosting provider of n0rthpine.com",
"how": "Find the IP address the site resolves to, look up who hosts that address, and note whether the site sits behind a CDN such as Cloudflare."
},
{
"item": "The messages from the two customers who wrote to support on 2 December",
"how": "Export both messages with their dates, and ask each customer for the receipt or bank statement line showing the 49.99 USD charge."
},
{
"item": "A record of the copied material",
"how": "Save the originals of the logo and the sign-in page text from northpine.com, with the date they were first published if you have it."
}
],
"reports": [
{
"channel": "registrar",
"to": "Abuse team of the registrar named in the WHOIS record",
"subject": "Request to suspend n0rthpine.com, a lookalike of northpine.com",
"body": "To the abuse team at [registrar name from WHOIS],\n\nI am writing for the owner of northpine.com about the domain n0rthpine.com, which is registered with you. n0rthpine.com imitates our real site, northpine.com, by using a zero in place of the letter 'o'. The site is not ours.\n\nCustomers forwarded us an email with the subject \"Your Northpine order is on hold\" that links to n0rthpine.com/account/verify. That page copies our sign-in page and our logo, then asks for the card number and CVV to \"release the order\". Two customers wrote to our support team on 2 December saying they were charged 49.99 USD and have no order with us. I first saw the site on [date you first saw the site].\n\nEvidence attached: the forwarded email with headers, dated screenshots of n0rthpine.com/account/verify, a side-by-side with the real sign-in page at northpine.com, and the WHOIS record from ICANN Lookup.\n\nRequest: please suspend the domain n0rthpine.com.\n\nThis site will also be reported to its hosting provider, to Google Safe Browsing, to the payment provider and to the host as a copyright notice.\n\nPlease confirm receipt and give a reference number.\n\n[your name and contact details]"
},
{
"channel": "host",
"to": "Abuse team of the hosting provider found from the site's IP address",
"subject": "Request to take down n0rthpine.com, a lookalike of northpine.com",
"body": "To the abuse team at [hosting provider],\n\nI am writing for the owner of northpine.com about the site n0rthpine.com, which is hosted with you. It imitates our real site, northpine.com, by using a zero in place of the letter 'o'. The site is not ours.\n\nCustomers forwarded us an email with the subject \"Your Northpine order is on hold\" that links to n0rthpine.com/account/verify. That page copies our sign-in page and our logo, then asks for the card number and CVV to \"release the order\". Two customers wrote to our support team on 2 December saying they were charged 49.99 USD and have no order with us. I first saw the site on [date you first saw the site].\n\nEvidence attached: the forwarded email with headers, dated screenshots of n0rthpine.com/account/verify, a side-by-side with the real sign-in page at northpine.com, and the IP address the site resolves to, [IP address of n0rthpine.com].\n\nRequest: please take down the content of n0rthpine.com.\n\nIf the site sits behind a CDN such as Cloudflare, the CDN's abuse form (abuse.cloudflare.com, \"Phishing & Malware\") will be used as well. The site will also be reported to the registrar, to Google Safe Browsing and to the payment provider.\n\nPlease confirm receipt and give a reference number.\n\n[your name and contact details]"
},
{
"channel": "safe_browsing",
"to": "Google Safe Browsing phishing report form",
"subject": "Phishing report: n0rthpine.com imitating northpine.com",
"body": "Reported URL: n0rthpine.com/account/verify\nReal site being imitated: northpine.com\n\nThe domain n0rthpine.com imitates northpine.com by using a zero in place of the letter 'o'. Customers forwarded an email with the subject \"Your Northpine order is on hold\" that links to n0rthpine.com/account/verify. That page copies the sign-in page and the logo of northpine.com, then asks for the card number and CVV to \"release the order\". Two customers wrote to the support team of northpine.com on 2 December saying they were charged 49.99 USD and have no order with us. The site is not owned by the owner of northpine.com.\n\nEvidence available: the forwarded email with headers, dated screenshots of the page, and a side-by-side with the real sign-in page at northpine.com.\n\nRequest: please flag n0rthpine.com as a phishing site so that browsers warn visitors before the page opens.\n\nThis site will also be reported to the registrar, to the hosting provider and to the payment provider.\n\nReporter: [your name and contact details]"
},
{
"channel": "payment",
"to": "Abuse or fraud team of the payment provider the fake site uses",
"subject": "Request to stop payments on n0rthpine.com, which imitates northpine.com",
"body": "To the fraud team at [payment provider shown at the fake checkout],\n\nI am writing for the owner of northpine.com about the site n0rthpine.com, which takes card payments. It imitates our real site, northpine.com, by using a zero in place of the letter 'o'. The site is not ours.\n\nCustomers forwarded us an email with the subject \"Your Northpine order is on hold\" that links to n0rthpine.com/account/verify. That page copies our sign-in page and our logo, then asks for the card number and CVV to \"release the order\". Two customers wrote to our support team on 2 December saying they were charged 49.99 USD and have no order with us. Their transaction references are [transaction references from the customers].\n\nEvidence attached: the forwarded email with headers, dated screenshots of n0rthpine.com/account/verify, a side-by-side with the real sign-in page at northpine.com, and the customers' receipts or bank statement lines.\n\nRequest: please stop processing payments for the merchant behind n0rthpine.com.\n\nThis site will also be reported to the registrar, to the hosting provider and to Google Safe Browsing.\n\nPlease confirm receipt and give a reference number.\n\n[your name and contact details]"
},
{
"channel": "dmca",
"to": "Copyright or abuse team of the hosting provider found from the site's IP address",
"subject": "Copyright takedown notice: copied sign-in page and logo at n0rthpine.com",
"body": "To the copyright agent at [hosting provider],\n\nI am writing for the owner of northpine.com. The site n0rthpine.com, which is hosted with you, copies our sign-in page text and our logo.\n\nOriginal work: the sign-in page text and the logo published at northpine.com.\nCopied material: the sign-in page text and the logo shown at n0rthpine.com/account/verify. That page asks for the card number and CVV to \"release the order\". The site is not ours, and we gave no permission to use our work.\n\nEvidence attached: dated screenshots of n0rthpine.com/account/verify and a side-by-side with the real sign-in page at northpine.com.\n\nRequest: please remove or disable access to the copied material at n0rthpine.com.\n\nI have a good faith belief that the use of this material in the way described is not authorised by the copyright owner, its agent or the law. The information in this notice is accurate, and I am authorised to act on behalf of the owner of the copyright.\n\nThe site will also be reported to the registrar, to Google Safe Browsing and to the payment provider.\n\n[your name, address and contact details]\n\n[signature]"
}
],
"support_reply": "Hello,\n\nThank you for telling us. The site n0rthpine.com is not affiliated with us. The only official site is northpine.com. If you paid or signed in at n0rthpine.com, please dispute the charge with your bank or card issuer. If you typed your password there, change it now. From now on, use only northpine.com.\n\n[how your team contacts customers]\n\n[support team name]",
"site_notice": "The only official address of our business is northpine.com. Any other domain, including n0rthpine.com, is not affiliated with us. Sign in and pay only at northpine.com.",
"plan": [
{
"when": "today",
"do": "Capture the evidence listed above, then send the registrar, host, Google Safe Browsing, payment provider and copyright reports at the same time, not one after another."
},
{
"when": "today",
"do": "Put the site notice on the sign-in page, the checkout and the footer of northpine.com."
},
{
"when": "today",
"do": "Send the support reply to the two customers who wrote on 2 December and to any other customer who paid or signed in at n0rthpine.com."
},
{
"when": "this week",
"do": "Run brand search ads for the name Northpine pointing to northpine.com, and post an announcement telling customers that the only official address is northpine.com."
},
{
"when": "this week",
"do": "Register the most convincing lookalike domains from the page's list so that no one else can use them."
},
{
"when": "ongoing",
"do": "Check the page's list of lookalike domains again every few weeks and follow up on each report if there is no reply."
}
]
}
On the page, each report shows with its own Copy button, the placeholders are listed under “Fill in before sending”, and the whole set downloads as Markdown.
Errors
| HTTP | What to do |
|---|---|
| 401 | The token is missing, expired or a guest token on a run. Get a personal token on the token page. |
| 402 | The balance is below what the run reserves. Top up at skillsafe.ai/account/billing. |
| 400 | The body is not a JSON object of the fields above. |
| 429 | Wait and retry with the same Idempotency-Key. |
Step 1 — a tiny client helper
One function that sends JSON and unwraps the {data, error} envelope.
BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here" # from https://lookalike-domain-generator.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://lookalike-domain-generator.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"]// lookalike-domain-generator.mjs -- Node 18+ (global fetch)
const BASE = "https://api.skillsafe.ai/v1/app-api";
let TOKEN = "paste-your-token-here"; // from https://lookalike-domain-generator.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://lookalike-domain-generator.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
}// LookalikeDomainGenerator.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 LookalikeDomainGenerator {
static final String BASE = "https://api.skillsafe.ai/v1/app-api";
static String token = "paste-your-token-here"; // from https://lookalike-domain-generator.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://lookalike-domain-generator.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://lookalike-domain-generator.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://lookalike-domain-generator.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 your personal token: sign in on the token page and copy it.
# 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":"lookalike-domain-generator"}' | 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": "lookalike-domain-generator"})["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: "lookalike-domain-generator" })).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": "lookalike-domain-generator"}, 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", "lookalike-domain-generator"), 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: "lookalike-domain-generator" })["token"])// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
$TOKEN = "";
$TOKEN = api("POST", "/guest", ["slug" => "lookalike-domain-generator"])["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 = "lookalike-domain-generator" }))!["token"]!.GetValue<string>();Step 3 — who am I, and my balance
subject_type is guest or user; credits is the balance (1 credit = $0.0001).
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 — price a run for free
/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.
# input.json: the run input object - {"task": "report", "official": "northpine.com", "suspect": "n0rthpine.com", "relation": "...", "notes": "...", "flags": "payments,copied"}
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": "report", "official": "northpine.com", "suspect": "n0rthpine.com", "relation": "...", "notes": "...", "flags": "payments,copied"}
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, official, suspect, relation, notes, flags}
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 — run it and wait for the job
Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.
KEY="lookalike-domain-generator:report:$(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: {relation, evidence, reports, support_reply, site_notice, plan}
echo "$J" | jq '.data | {charged_credits, truncated}' import hashlib, time
key = "lookalike-domain-generator:" + 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"]) # {relation, evidence, reports, support_reply, site_notice, plan}
print(j["charged_credits"], j.get("truncated"), reply.get("reports"))import { createHash } from "node:crypto";
const key = `lookalike-domain-generator:${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.reports);sum := sha256.Sum256(raw) // add "crypto/sha256", "encoding/hex", "time" to the imports
key := "lookalike-domain-generator:" + 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 = "lookalike-domain-generator:" + 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 = "lookalike-domain-generator:#{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["reports"]].inspect$key = "lookalike-domain-generator:" . $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["reports"], "\n";var digest = System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(input.ToJsonString()));
var key = $"lookalike-domain-generator:{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 — or stream it
/run-stream sends Server-Sent Events while the job runs and the finished job at the end.
# 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: lookalike-domain-generator:report:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.jsonrin = json.load(open("input.json")) # {"task": "report", "official": "northpine.com", "suspect": "n0rthpine.com", "relation": "...", "notes": "...", "flags": "payments,copied"}
req = urllib.request.Request(BASE + "/run-stream", method="POST", data=json.dumps(rin).encode(),
headers={"Content-Type": "application/json", "Authorization": "Bearer " + TOKEN,
"Idempotency-Key": "lookalike-domain-generator:report:" + 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("input.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": `lookalike-domain-generator:report:${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("input.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", "lookalike-domain-generator:report:"+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("input.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", "lookalike-domain-generator:report:" + 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("input.json")
uri = URI(BASE + "/run-stream")
req = Net::HTTP::Post.new(uri, "Content-Type" => "application/json", "Authorization" => "Bearer #{TOKEN}",
"Idempotency-Key" => "lookalike-domain-generator:report:#{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("input.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: lookalike-domain-generator:report:" . 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("input.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", $"lookalike-domain-generator:report:{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);