wheels-api-generator

wheels-dev's avatarfrom wheels-dev

Generate RESTful API controllers with JSON responses, proper HTTP status codes, and API authentication. Use when creating API endpoints, JSON APIs, or web services. Ensures proper REST conventions and error handling.

⭐200stars🔀107forks📁View on GitHub🕐Updated Jan 1, 2026

When & Why to Use This Skill

The Wheels API Generator is a specialized Claude skill designed to streamline the development of RESTful API controllers. It automates the creation of JSON-based endpoints, ensuring strict adherence to REST conventions, standardized HTTP status codes, and built-in API authentication. By providing a robust template for CRUD operations and error handling, it helps developers build secure, scalable, and consistent web services efficiently.

Use Cases

  • Rapid API Prototyping: Quickly scaffold complete CRUD controllers for new database resources to accelerate backend development cycles.
  • Standardizing Response Formats: Ensure all web services return uniform JSON structures and appropriate HTTP status codes (e.g., 201 for creation, 422 for validation errors) for seamless frontend integration.
  • Implementing Secure Endpoints: Automatically integrate Bearer token authentication and request verification filters to protect sensitive data and ensure authorized access.
  • Legacy System Modernization: Transform existing web logic into modern RESTful services by generating standardized controller wrappers with proper error handling.
nameWheels API Generator
descriptionGenerate RESTful API controllers with JSON responses, proper HTTP status codes, and API authentication. Use when creating API endpoints, JSON APIs, or web services. Ensures proper REST conventions and error handling.

Wheels API Generator

When to Use This Skill

Activate when:

  • User requests to create an API
  • User wants JSON endpoints
  • User mentions: API, REST, JSON, endpoint, web service

API Controller Template

component extends="Controller" {

    function config() {
        provides("json");
        verifies(only="show,update,delete", params="key", paramsTypes="integer");
        filters(through="requireApiAuth");
    }

    function index() {
        resources = model("Resource").findAll(order="createdAt DESC");

        renderWith(
            data=resources,
            format="json",
            status=200
        );
    }

    function show() {
        resource = model("Resource").findByKey(key=params.key);

        if (!isObject(resource)) {
            renderWith(
                data={error="Resource not found"},
                format="json",
                status=404
            );
            return;
        }

        renderWith(
            data=resource,
            format="json",
            status=200
        );
    }

    function create() {
        resource = model("Resource").new(params.resource);

        if (resource.save()) {
            renderWith(
                data=resource,
                format="json",
                status=201,
                location=urlFor(action="show", key=resource.key())
            );
        } else {
            renderWith(
                data={errors=resource.allErrors()},
                format="json",
                status=422
            );
        }
    }

    function update() {
        resource = model("Resource").findByKey(key=params.key);

        if (!isObject(resource)) {
            renderWith(data={error="Not found"}, format="json", status=404);
            return;
        }

        if (resource.update(params.resource)) {
            renderWith(data=resource, format="json", status=200);
        } else {
            renderWith(data={errors=resource.allErrors()}, format="json", status=422);
        }
    }

    function delete() {
        resource = model("Resource").findByKey(key=params.key);

        if (!isObject(resource)) {
            renderWith(data={error="Not found"}, format="json", status=404);
            return;
        }

        resource.delete();
        renderWith(data={message="Deleted"}, format="json", status=204);
    }

    private function requireApiAuth() {
        var headers = getHTTPRequestData().headers;

        if (!structKeyExists(headers, "Authorization")) {
            renderWith(data={error="Unauthorized"}, format="json", status=401);
            abort;
        }

        // Validate API token
        var token = replace(headers.Authorization, "Bearer ", "");
        if (!isValidApiToken(token)) {
            renderWith(data={error="Invalid token"}, format="json", status=401);
            abort;
        }
    }

    private boolean function isValidApiToken(required string token) {
        // Token validation logic
        return true;
    }
}

HTTP Status Codes

  • 200 OK: Successful GET, PUT, PATCH
  • 201 Created: Successful POST
  • 204 No Content: Successful DELETE
  • 400 Bad Request: Invalid request data
  • 401 Unauthorized: Missing/invalid authentication
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Resource doesn't exist
  • 422 Unprocessable Entity: Validation errors
  • 500 Internal Server Error: Server error

Generated by: Wheels API Generator Skill v1.0