Guides
Recipes
Small scripts that do real work: a daily digest, a transcript archive, repository health, demand comparison and a bulk URL pass.
Daily Hacker News digest
Fetch the top stories and print titles with scores. The endpoint costs 1 credit per call and caches briefly, so a cron job does not pay twice for the same minute.
digest.sh
#!/usr/bin/env bash
set -euo pipefail
curl -s "https://api.cleanfetch.dev/v1/hackernews/top?limit=10" \
-H "x-api-key: $CLEANFETCH_API_KEY" \
| jq -r '.data.items[] | "\(.score)\t\(.title)"'Archive a YouTube transcript
Transcript lookups return timestamped snippets. Write the joined text next to the video id so the file is easy to diff and search later.
transcript.sh
#!/usr/bin/env bash
set -euo pipefail
VIDEO="dQw4w9WgXcQ"
curl -s "https://api.cleanfetch.dev/v1/youtube/transcript?v=$VIDEO" \
-H "x-api-key: $CLEANFETCH_API_KEY" \
| jq -r '.data.snippets[].text' > "$VIDEO.txt"Repository health snapshot
One call returns stars, forks, language, license and the latest push. Store the JSON and compare the numbers on the next run.
repo.sh
#!/usr/bin/env bash
set -euo pipefail
curl -s "https://api.cleanfetch.dev/v1/github/repo?url=https://github.com/vercel/next.js" \
-H "x-api-key: $CLEANFETCH_API_KEY" \
| jq '{stars: .data.stars, forks: .data.forks, pushed: .data.pushedAt}'Compare demand for two terms
Google Trends interest accepts up to five keywords and returns a relative series. Compare the series, not the absolute values, and keep the requested geo in the filename.
trends.sh
#!/usr/bin/env bash
set -euo pipefail
curl -s https://api.cleanfetch.dev/v1/google-trends/interest \
-H "x-api-key: $CLEANFETCH_API_KEY" \
-H "content-type: application/json" \
-d '{"keywords":["cleanfetch","scraping api"],"geo":"US"}' \
| jq '.data | {keywords, points: (.points | length), average}'Bulk public URLs
Read URLs from a file, call one endpoint per line, and keep going when a single lookup misses. The meta block makes it obvious which rows were billed.
bulk.sh
#!/usr/bin/env bash
set -euo pipefail
while IFS= read -r URL; do
[ -z "$URL" ] && continue
curl -sG https://api.cleanfetch.dev/v1/x/profile \
-H "x-api-key: $CLEANFETCH_API_KEY" \
--data-urlencode "url=$URL" \
| jq -c '{url: .data.url, followers: .data.followers, billed: .meta.creditsCharged}'
done < urls.txt