api-client-template

SocketDev's avatarfrom SocketDev

Template for creating API integration skills. Copy and customize for your specific API.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 6, 2026

When & Why to Use This Skill

The API Client Template is a professional-grade boilerplate designed to accelerate the development of custom Claude skills for API integrations. It provides a standardized framework for handling authentication, RESTful endpoints, complex pagination, and robust error management, enabling developers to quickly connect Claude to any external web service with production-ready Python code.

Use Cases

  • Rapidly bootstrapping new Claude skills that require secure integration with third-party SaaS platforms or internal REST APIs.
  • Standardizing API interaction logic across multiple agentic workflows to ensure consistent error handling and rate-limit management.
  • Implementing efficient data retrieval from external services using pre-built pagination templates for large datasets.
  • Reducing development overhead when building custom tools for Claude to perform CRUD operations on external databases via webhooks.
nameapi-client-template
descriptionTemplate for creating API integration skills. Copy and customize for your specific API.

API Client Template

Authentication

  • Base URL: https://api.example.com/v1
  • Auth: [Basic Auth / Bearer Token / API Key]
  • Header: Authorization: [Basic/Bearer] {TOKEN}
  • Environment variable: EXAMPLE_API_TOKEN

Endpoints

Endpoint Method Description
/resources GET List resources
/resources/{id} GET Get specific resource
/resources POST Create resource
/resources/{id} PUT Update resource
/resources/{id} DELETE Delete resource

Pagination

  • limit - Max items per request (typically 100)
  • offset or cursor - Position in result set

Python Client

import os
import requests
from typing import Dict, Optional, List

class ExampleClient:
    def __init__(self):
        self.base_url = "https://api.example.com/v1"
        token = os.getenv("EXAMPLE_API_TOKEN")
        if not token:
            raise ValueError("EXAMPLE_API_TOKEN environment variable required")
        self.headers = {
            "Authorization": f"Bearer {token}",
            "Content-Type": "application/json"
        }

    def _request(
        self,
        method: str,
        endpoint: str,
        params: Optional[Dict] = None,
        json: Optional[Dict] = None
    ) -> Dict:
        url = f"{self.base_url}{endpoint}"
        response = requests.request(
            method, url,
            headers=self.headers,
            params=params,
            json=json,
            timeout=30
        )
        response.raise_for_status()
        if response.status_code == 204:
            return {}
        return response.json()

    def list_resources(self, limit: int = 100) -> List[Dict]:
        """Paginate through all resources."""
        resources = []
        cursor = None
        while True:
            params = {"limit": limit}
            if cursor:
                params["cursor"] = cursor
            data = self._request("GET", "/resources", params=params)
            resources.extend(data.get("results", []))
            cursor = data.get("next_cursor")
            if not cursor:
                break
        return resources

    def get_resource(self, resource_id: str) -> Dict:
        return self._request("GET", f"/resources/{resource_id}")

    def create_resource(self, payload: Dict) -> Dict:
        return self._request("POST", "/resources", json=payload)

Error Handling

  • 401 - Unauthorized (check token)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Resource not found
  • 429 - Rate limited (check retry-after header)

Environment Variables

export EXAMPLE_API_TOKEN=your-token-here