Skip to content
Back to skills

Api Fetch Wrapper

ASecurity

Wrap a public HTTP API (Open-Meteo weather as the demo) with credential handling, error normalisation, and a single retry on transient network failures. Demonstrates the production-shaped baseline for any "skill that calls an external service" — env-based secrets, structured error output, no leaked API keys in logs, and a deliberate retry policy. The Open-Meteo endpoint used here is keyless on purpose so the example runs without setup; replace `OPEN_METEO_URL` with your own host and add `proc...

  • 20 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 26, 2026
ai-agentstypescriptgobashgitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add ChronoAIProject/Ornn --skill api-fetch-wrapper --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Fetch Wrapper?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Fetch Wrapper
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/chronoaiproject-api-fetch-wrapper/badge)](https://www.skillsdirectory.com/skills/chronoaiproject-api-fetch-wrapper)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-fetch-wrapper
description: Wrap a public HTTP API (Open-Meteo weather as the demo) with credential handling, error normalisation, and a single retry on transient network failures. Demonstrates the production-shaped baseline for any "skill that calls an external service" — env-based secrets, structured error output, no leaked API keys in logs, and a deliberate retry policy. The Open-Meteo endpoint used here is keyless on purpose so the example runs without setup; replace `OPEN_METEO_URL` with your own host and add `process.env.MY_API_KEY` for an auth'd version.
version: "1.0"
license: MIT
metadata:
  category: integration
  tag:
    - example
    - http
    - external-api
    - typescript
---

# api-fetch-wrapper

The case that breaks first in production — a skill that hits an external service. This example covers the four things every such skill needs: secret handling, retry policy, error normalisation, and no-leak-on-failure logging.

## Contract

**Input** (stdin, JSON):

```json
{ "latitude": 52.52, "longitude": 13.41 }
```

**Output** (stdout, JSON):

```json
{
  "temperatureC": 18.4,
  "windSpeedKmh": 12.6,
  "fetchedAt": "2026-05-19T08:00:00.000Z"
}
```

**Errors** — written to stderr as `{"error": "...", "cause": "..."}` and exit code `1`. Error messages NEVER include the raw upstream response body (it might echo a secret); they include the upstream status code and a short canonical reason.

## Required environment

| Var | Purpose |
|---|---|
| `OPEN_METEO_URL` | Optional override of the upstream host. Defaults to `https://api.open-meteo.com`. |
| *(none for auth)* | Open-Meteo is keyless. For an auth'd API, the same skeleton reads `process.env.YOUR_API_KEY` and passes it via `Authorization` header. |

## Run locally

```bash
cd examples/api-fetch-wrapper
bun install
echo '{"latitude":52.52,"longitude":13.41}' | bun run src/index.ts
```

## Adapt this

- **Different API** — replace the URL, query params, and response shape. The retry / error-mapping skeleton stays.
- **API-key auth** — read `process.env.YOUR_API_KEY` once at the top, pass it via `Authorization: Bearer ${apiKey}`, and ensure the key never appears in error messages.
- **Stronger retry** — bump `MAX_ATTEMPTS`, add exponential backoff with jitter, or distinguish 5xx (retry) vs 4xx (do not retry) explicitly.
- **Cache** — wrap the fetch in a TTL cache when the upstream rate-limits.

Files in this skill

  • README.md470 B
  • SKILL.md2.4 KB
  • package.json282 B
  • src/index.ts3.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.