Skip to content

Scripts

DannylydST edited this page Aug 6, 2026 · 1 revision

Helper Scripts

All scripts are POSIX bash 4+ (macOS / Linux / Windows Git Bash / WSL). They wrap the raw sorftime api command with output cleaning, error handling, and automation features.

Quick Reference

Script What it does Example
call.sh Single API call, cleaned output, exit-code 2 on business error bash scripts/call.sh ProductRequest '{"asin":"B0CVM8TXHP"}' --domain 1
one.sh One-line status: 11 key fields for one ASIN/keyword/category bash scripts/one.sh ProductRequest B0CVM8TXHP
batch.sh Generic batch runner: loop any endpoint over a file bash scripts/batch.sh ProductRequest asins.txt --param asin --out out.jsonl
doctor.sh Environment self-check with onboarding hints bash scripts/doctor.sh --connect
decode.sh Error-code dictionary (no API call needed) bash scripts/decode.sh 10
gen-index.sh Regenerates the endpoint count matrix bash scripts/gen-index.sh
_lib.sh Shared library (call_api / _pyq / py_field / py_to_csv) sourced by all others

batch.sh — the automation workhorse

Input file: one JSON params object per line, or bare values with --param:

# asins.txt: one ASIN per line
cat > asins.txt << 'EOF'
B0CVM8TXHP
B08N5WRWNW
EOF

# Run the batch with rate limiting (1s default), retries, and disk output
bash scripts/batch.sh ProductRequest asins.txt --param asin --domain 1 --out products.jsonl
# → batch done: 2 ok / 0 failed / 2 lines

# Resume an interrupted batch (skips completed lines)
bash scripts/batch.sh ProductRequest asins.txt --param asin --out products.jsonl --resume

# Dry-run: preview every command without paying API calls
bash scripts/batch.sh ProductRequest asins.txt --param asin --dry-run

Options: --domain N · --profile X · --sleep S (seconds between calls, default 1) · --retries R (default 2) · --out FILE · --param NAME · --resume · --dry-run

Exit codes: 0 all succeeded · 2 some failed · 3 bad input.

doctor.sh

bash scripts/doctor.sh          # node/npm/CLI/profile checks
bash scripts/doctor.sh --connect  # + live API call (CategoryTree, domain 1)

Every failed check prints the exact fix (install command, profile setup, proxy hints).

Exit codes (call.sh / one.sh / batch.sh)

  • 0 — API code=0 (success)
  • 2 — API code≠0 (business error, message on stderr)
  • 3 — Bad input
  • 4 — Network / CLI error (auto-retry with --retries N)

Sorftime Data CLI Skill

Clone this wiki locally