api-endpoints

Build RESTful JSON API endpoints for AFAL Rails applications.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill api-endpoints-grupo-afal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-endpoints
Source: https://github.com/Grupo-AFAL/claude-plugins/tree/main/rails-tools/skills/api-endpoints
Command: npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill api-endpoints-grupo-afal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Create consistent, secure, and testable REST JSON endpoints for AFAL Rails applications so teams avoid ad-hoc API implementations, mismatched serializers, and brittle pagination/filtering logic.

Core Features & Use Cases

  • Blueprinter serialization configured with composable views for list and full responses and association handling.
  • Pagy pagination integrated into controllers with a standardized pagination_meta shape.
  • Ransack filtering and sorting with required ransackable whitelists on models to prevent unsafe queries.
  • Controller patterns & error handling including a Api::V1::BaseController with authorization hooks (Pundit), API error concern, and plain JSON response shapes.
  • Minitest integration tests and fixtures for integration-level verification of auth, pagination, filtering, and error responses.
  • Use Case: Implement Api::V1::Projects endpoints that return paginated, filterable JSON lists and detailed show responses serialized by ProjectBlueprint.

Quick Start

Generate an Api::V1 resource controller that uses Blueprinter for serialization, Pagy for pagination, Ransack for filtering, Pundit for authorization, and include Minitest integration tests.

Frequently Asked Questions about api-endpoints

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

FAQPage Schema
How do I build a Rails JSON API with consistent pagination and filtering?

Build Rails JSON APIs by applying standardized controller patterns that integrate Pagy for pagination and Ransack for filtering. This approach enforces consistent pagination_meta shapes and ransackable whitelists to prevent unsafe queries across REST endpoints.

How do I secure a Rails API endpoint with Pundit authorization?

Secure Rails API endpoints by implementing an Api::V1::BaseController with Pundit authorization hooks. This pattern enforces authorization policies before serialization and includes Minitest integration tests to verify access control and error responses.

What is the best way to serialize JSON responses in a Rails API?

Serialize JSON responses in Rails APIs using Blueprinter, which supports composable views for list and full responses. This ensures consistent JSON output structures and handles model associations effectively across standard CRUD workflows.

How does Ransack filtering work with Rails API controllers?

Ransack filtering in Rails API controllers requires defining ransackable whitelists on models to prevent unsafe queries. This mechanism allows users to filter and sort JSON API resources dynamically while maintaining strict query security boundaries.

Can I use Pagy and Blueprinter together in a Rails API controller?

Yes, you can use Pagy and Blueprinter together in Rails API controllers to combine efficient pagination with structured JSON serialization. This integration produces paginated, filterable JSON lists with a standardized pagination_meta shape.

Why do I need ransackable whitelists when building Rails JSON APIs?

Ransackable whitelists are needed when building Rails JSON APIs to prevent unsafe database queries during filtering and sorting. Defining these whitelists on models explicitly restricts which attributes users can query, securing the API endpoint against unauthorized data access.