Build reusable CLI scripts for Hugging Face API workflows
Builds reusable command-line scripts and utilities for the Hugging Face API, enabling chaining, piping, and automation of model, dataset, and space queries.
Why it matters
Generate command-line scripts and utilities that interact with the Hugging Face API, enabling users to automate model discovery, dataset queries, and metadata enrichment through composable, pipeable tools that can be chained together for complex workflows.
Outcomes
What it gets done
Create authenticated shell, Python, or TypeScript scripts that fetch data from Hugging Face API endpoints
Build composable utilities that accept stdin and emit NDJSON for streaming pipeline integration
Generate scripts with proper help documentation, error handling, and HF_TOKEN authorization
Chain multiple API calls together to enrich model metadata, parse cards, and filter results
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-huggingface-tool-builder | bash Overview
Hugging Face API Tool Builder
Hugging Face API Tool Builder creates reusable command-line scripts and utilities that interact with the Hugging Face API. It generates shell, Python, or TypeScript scripts that fetch, enrich, and process data from models, datasets, spaces, collections, and papers, with support for chaining and piping operations for composable workflows. Use this skill when you need to build tools or scripts that leverage Hugging Face API data, especially for tasks that will be repeated or automated. It excels at chaining or combining multiple API calls, such as fetching trending models, enriching metadata, and parsing model cards. Use it when you need composable utilities that integrate into shell pipelines.
What it does
Hugging Face API Tool Builder creates reusable command-line scripts and utilities that interact with the Hugging Face API. It generates shell, Python, or TypeScript scripts that fetch, enrich, and process data from models, datasets, spaces, collections, and papers, with support for chaining and piping operations for composable workflows.
When to use - and when NOT to
Use this skill when you need to build tools or scripts that leverage Hugging Face API data, especially for tasks that will be repeated or automated. It excels at chaining or combining multiple API calls, such as fetching trending models, enriching metadata, and parsing model cards. Use it when you need composable utilities that integrate into shell pipelines.
Do not use this skill for tasks outside the Hugging Face API scope. Verify commands, API behavior, quotas, and credentials against current official documentation before making changes. Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
Inputs and outputs
You provide the task description and preferences (e.g., which API endpoints to query, desired output format, scripting language preference). The skill creates scripts following specific rules: scripts must take a --help command line argument to describe their inputs and outputs, non-destructive scripts should be tested before handover, and scripts use the HF_TOKEN environment variable as an Authorization header for higher rate limits and appropriate authorization.
Integrations
The skill works with the Hugging Face API endpoints available at https://huggingface.co including:
/api/models- search and retrieve model metadata/api/datasets- query dataset information/api/spaces- access Spaces data/api/collections- fetch collection details/api/daily_papers- retrieve daily papers/api/trending- get trending content/api/whoami-v2- user authentication info/api/notifications- notifications/api/settings- settings/oauth/userinfo- OAuth user information
The skill can access the API directly and use the hf command line tool. The API is documented with the OpenAPI standard at https://huggingface.co/.well-known/openapi.json. Scripts can query this specification to extract endpoint details:
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths | keys | sort'
Example querying a specific endpoint:
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths["/api/models"]'
Who it's for
This skill serves developers and data scientists who need programmatic access to Hugging Face resources for automation, batch processing, or integration into larger workflows. It's ideal for users building CI/CD pipelines, data collection systems, or research tools that require repeatable queries across models, datasets, and papers. The composable design suits users comfortable with Unix-style command chaining and JSON processing.
Source README
Hugging Face API Tool Builder
When to Use
Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful when chaining or combining API calls or the task will be repeated/automated. This Skill creates a reusable script to fetch, enrich...
Your purpose is now is to create reusable command line scripts and utilities for using the Hugging Face API, allowing chaining, piping and intermediate processing where helpful. You can access the API directly, as well as use the hf command line tool. Model and Dataset cards can be accessed from repositories directly.
Script Rules
Make sure to follow these rules:
- Scripts must take a
--helpcommand line argument to describe their inputs and outputs - Non-destructive scripts should be tested before handing over to the User
- Shell scripts are preferred, but use Python or TSX if complexity or user need requires it.
- IMPORTANT: Use the
HF_TOKENenvironment variable as an Authorization header. For example:curl -H "Authorization: Bearer ${HF_TOKEN}" https://huggingface.co/api/. This provides higher rate limits and appropriate authorization for data access. - Investigate the shape of the API results before commiting to a final design; make use of piping and chaining where composability would be an advantage - prefer simple solutions where possible.
- Share usage examples once complete.
Be sure to confirm User preferences where there are questions or clarifications needed.
Sample Scripts
Paths below are relative to this skill directory.
Reference examples:
references/hf_model_papers_auth.sh- usesHF_TOKENautomatically and chains trending → model metadata → model card parsing with fallbacks; it demonstrates multi-step API usage plus auth hygiene for gated/private content.references/find_models_by_paper.sh- optionalHF_TOKENusage via--token, consistent authenticated search, and a retry path when arXiv-prefixed searches are too narrow; it shows resilient query strategy and clear user-facing help.references/hf_model_card_frontmatter.sh- uses thehfCLI to download model cards, extracts YAML frontmatter, and emits NDJSON summaries (license, pipeline tag, tags, gated prompt flag) for easy filtering.
Baseline examples (ultra-simple, minimal logic, raw JSON output with HF_TOKEN header):
references/baseline_hf_api.sh- bashreferences/baseline_hf_api.py- pythonreferences/baseline_hf_api.tsx- typescript executable
Composable utility (stdin → NDJSON):
references/hf_enrich_models.sh- reads model IDs from stdin, fetches metadata per ID, emits one JSON object per line for streaming pipelines.
Composability through piping (shell-friendly JSON output):
references/baseline_hf_api.sh 25 | jq -r '.[].id' | references/hf_enrich_models.sh | jq -s 'sort_by(.downloads) | reverse | .[:10]'references/baseline_hf_api.sh 50 | jq '[.[] | {id, downloads}] | sort_by(.downloads) | reverse | .[:10]'printf '%s\n' openai/gpt-oss-120b meta-llama/Meta-Llama-3.1-8B | references/hf_model_card_frontmatter.sh | jq -s 'map({id, license, has_extra_gated_prompt})'
High Level Endpoints
The following are the main API endpoints available at https://huggingface.co
/api/datasets
/api/models
/api/spaces
/api/collections
/api/daily_papers
/api/notifications
/api/settings
/api/whoami-v2
/api/trending
/oauth/userinfo
Accessing the API
The API is documented with the OpenAPI standard at https://huggingface.co/.well-known/openapi.json.
IMPORTANT: DO NOT ATTEMPT to read https://huggingface.co/.well-known/openapi.json directly as it is too large to process.
IMPORTANT Use jq to query and extract relevant parts. For example,
Command to Get All 160 Endpoints
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths | keys | sort'
Model Search Endpoint Details
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths["/api/models"]'
You can also query endpoints to see the shape of the data. When doing so constrain results to low numbers to make them easy to process, yet representative.
Using the HF command line tool
The hf command line tool gives you further access to Hugging Face repository content and infrastructure.
❯ hf --help
Usage: hf [OPTIONS] COMMAND [ARGS]...
Hugging Face Hub CLI
Options:
--help Show this message and exit.
Commands:
auth Manage authentication (login, logout, etc.).
buckets Commands to interact with buckets.
cache Manage local cache directory.
collections Interact with collections on the Hub.
datasets Interact with datasets on the Hub.
discussions Manage discussions and pull requests on the Hub.
download Download files from the Hub.
endpoints Manage Hugging Face Inference Endpoints.
env Print information about the environment.
extensions Manage hf CLI extensions.
jobs Run and manage Jobs on the Hub.
models Interact with models on the Hub.
papers Interact with papers on the Hub.
repos Manage repos on the Hub.
skills Manage skills for AI assistants.
spaces Interact with spaces on the Hub.
sync Sync files between local directory and a bucket.
upload Upload a file or a folder to the Hub.
upload-large-folder Upload a large folder to the Hub.
version Print information about the hf version.
webhooks Manage webhooks on the Hub.
The hf CLI command has replaced the now deprecated huggingface-cli command.
Limitations
- Use this skill only when the task clearly matches its upstream product or API scope.
- Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
- Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.