Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chocodata-cli

Command-line interface for the Chocodata web scraping API. Scrape from a terminal or a shell script, get JSON or NDJSON.

npm install -g chocodata-cli
chocodata login asa_live_YOUR_KEY

Node 18+. Get a key at chocodata.com; the free tier is 1,000 requests, one time, no card.

Usage

chocodata <target> <resource> [--param value]

The CLI mirrors the API's own shape: a target, a resource, then that endpoint's parameters as flags.

chocodata amazon product --query 0143127748
chocodata amazon product --query 0143127748 --domain de
chocodata amazon search --query laptop

chocodata walmart product --url https://www.walmart.com/ip/19075520026
chocodata ebay product --url https://www.ebay.com/itm/298520538688

chocodata bing search --q coffee --count 10
chocodata bing images --q "red panda" --count 20 --safe_search strict

chocodata tiktok profile --username rotana
chocodata youtube video --video_id dQw4w9WgXcQ
chocodata instagram profile --username nasa

Parameters differ per endpoint, and the CLI passes flags through rather than inventing a uniform surface it cannot honour: amazon product takes --query, walmart product takes --url or --id and rejects --query, bing search takes --q. All 499 endpoints work this way, including ones not listed above. Browse them at chocodata.com/scraper-api.

Batch from a file

--stdin-param reads values from stdin, one per line, and feeds them into a parameter. With --ndjson you get one compact object per line, ready for jq or a warehouse loader.

cat asins.txt | chocodata amazon product --stdin-param query --ndjson > out.ndjson

# with jq
cat asins.txt | chocodata amazon product --stdin-param query --ndjson \
  | jq -r '[.asin, .title, .price] | @csv'

Errors go to stderr and successful rows to stdout, so a partial failure still leaves you a clean NDJSON stream.

Authentication

In order of precedence:

  1. CHOCODATA_API_KEY environment variable
  2. ~/.chocodata/config.json, written by chocodata login with 0600 permissions
chocodata whoami    # shows which key is in use, masked

Flags

Flag Meaning
--ndjson One compact JSON object per line. Default is pretty-printed JSON.
--stdin-param <name> Read values from stdin, one per line, into that parameter.
--debug Log every HTTP call to stderr with timings.
--help Usage and examples.

Exit codes

0 on success. 1 if the request failed (or, in batch mode, if every row failed). The error line carries the status, the API's error code, and the request id for support:

error 404 item_not_found: That TikTok handle does not resolve: it has been
deleted, renamed, or is unavailable in this region. (request d2f460a7-...)

You are only charged on a 2xx. Errors cost no credits. Retryable failures (429, 5xx, network) are retried automatically with backoff.

License

MIT

About

Command-line interface for the Chocodata web scraping API.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages