api-script

Generate Python CLI scripts that fetch REST API data into PostgreSQL.

Updated Mar 7, 2026
One-click install
npx skills add https://github.com/randoneering/nix-flake-mirror --skill api-script
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-script
Source: https://github.com/randoneering/nix-flake-mirror/tree/main/home/programs/opencode/skills/python/api-script
Command: npx skills add https://github.com/randoneering/nix-flake-mirror --skill api-script

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests, psycopg2, and includes references (resource) components.

What problem does it solve?

Automate the creation of Python scripts that fetch data from REST APIs and persist results to PostgreSQL, reducing manual coding and boilerplate.

Core Features & Use Cases

  • Single-file Python scripts with a CLI (argparse) and subcommands for daily, range, and last-day fetches.
  • Built-in HTTP requests handling with timeouts, retries, and structured error reporting.
  • Upsert logic to insert or update records in PostgreSQL, ensuring idempotent runs.
  • Optional authentication patterns and reference templates for common API providers.

Quick Start

Provide your API base URL, authentication method, and target PostgreSQL connection to generate a ready-to-run data-fetching script.

Frequently Asked Questions about api-script

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate fetching data from a REST API and storing it in PostgreSQL using Python?

You can automate fetching REST API data and storing it in PostgreSQL by generating a single-file Python script with CLI arguments, built-in HTTP retries, and PostgreSQL upsert logic for durable, repeatable data ingestion.

Can I generate a Python CLI script that handles REST API authentication and error handling automatically?

Yes, generated Python CLI scripts include built-in HTTP request handling with timeouts, structured error reporting, retries, and optional authentication patterns to support robust REST API data ingestion workflows.

Does api-script support idempotent data ingestion to avoid duplicate records in PostgreSQL?

Yes, api-script supports idempotent data ingestion by implementing upsert logic that automatically inserts new records or updates existing ones in your PostgreSQL database during repeat API data pulls.

What is the best way to schedule recurring REST API data pulls for weather or IoT data?

The best way to schedule recurring REST API data pulls is using the generated Python script's built-in argparse subcommands for daily, range, and last-day fetches, ensuring deterministic and repeatable data ingestion.

Do I need to install requests and psycopg2 to run the generated Python API scripts?

Yes, you need to install the requests and psycopg2 Python packages, as these dependencies provide the required HTTP request capabilities and PostgreSQL database connection functionality for the generated data ingestion scripts.

What limitations should I consider when using Python scripts for REST API data ingestion?

Consider that these Python scripts are designed for deterministic, CLI-driven REST API data ingestion into PostgreSQL, meaning they focus on single-file automation and may require manual customization for complex streaming or non-REST API integrations.