processing-api-batches

0
0
Source

Optimize bulk API requests with batching, throttling, and parallel execution. Use when processing bulk API operations efficiently. Trigger with phrases like "process bulk requests", "batch API calls", or "handle batch operations".

Install

mkdir -p .claude/skills/processing-api-batches && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4739" && unzip -o skill.zip -d .claude/skills/processing-api-batches && rm skill.zip

Installs to .claude/skills/processing-api-batches

About this skill

Processing API Batches

Overview

Optimize bulk API operations with batch request endpoints, parallel execution with concurrency control, partial failure handling, and progress tracking. Implement batch processing patterns that accept arrays of operations in a single request, execute them efficiently with database bulk operations, and return per-item results with individual success/failure status.

Prerequisites

  • Web framework capable of handling large request bodies (configure body size limits: 10MB+ for batch payloads)
  • Database with bulk operation support (bulk insert, bulk update, transactions)
  • Queue system for async batch processing: Bull/BullMQ (Node.js), Celery (Python), or SQS
  • Progress tracking store (Redis) for long-running batch status polling
  • Rate limiting aware of batch operations (count individual operations, not just requests)

Instructions

  1. Examine existing API endpoints using Read and Grep to identify operations frequently called in loops by consumers, which are candidates for batch equivalents.
  2. Design the batch request format: accept an array of operations in the request body, each with an optional client-provided id for result correlation, e.g., POST /batch with {operations: [{method: "POST", path: "/users", body: {...}, id: "op1"}]}.
  3. Implement synchronous batch processing for small batches (< 100 items): validate all items, execute in a database transaction, and return per-item results with {id, status, result|error} for each operation.
  4. Add asynchronous batch processing for large batches (> 100 items): accept the batch, return 202 Accepted with a batchId and status polling URL, process in a background worker, and update progress in Redis.
  5. Implement concurrency control: process batch items in parallel with configurable concurrency limit (default: 10) using p-limit or asyncio.Semaphore to prevent database connection exhaustion.
  6. Handle partial failures: do not abort the entire batch when individual items fail; collect per-item results with success/failure status, and return the batch result with summary counts (succeeded, failed, total).
  7. Add progress tracking for async batches: expose GET /batch/:batchId/status returning {total, completed, failed, progress: 0.75, status: "processing|completed|failed"}.
  8. Implement batch size limits and validation: maximum 1000 items per batch, reject oversized batches with 413, validate all items before processing any, and return all validation errors upfront.
  9. Write tests covering: small sync batches, large async batches, partial failure handling, progress tracking, concurrency limits, and batch size validation.

See ${CLAUDE_SKILL_DIR}/references/implementation.md for the full implementation guide.

Output

  • ${CLAUDE_SKILL_DIR}/src/routes/batch.js - Batch request endpoint with sync/async routing
  • ${CLAUDE_SKILL_DIR}/src/batch/processor.js - Batch execution engine with concurrency control
  • ${CLAUDE_SKILL_DIR}/src/batch/validator.js - Batch request validation and size limit enforcement
  • ${CLAUDE_SKILL_DIR}/src/batch/progress.js - Redis-backed progress tracking for async batches
  • ${CLAUDE_SKILL_DIR}/src/batch/workers/ - Background worker for async batch processing
  • ${CLAUDE_SKILL_DIR}/src/batch/results.js - Per-item result aggregation with summary statistics
  • ${CLAUDE_SKILL_DIR}/tests/batch/ - Batch processing integration tests

Error Handling

ErrorCauseSolution
413 Payload Too LargeBatch exceeds maximum item count (1000) or body size limitReturn clear error with maximum allowed count; suggest splitting into multiple batch requests
207 Multi-StatusSome batch items succeeded while others failedReturn per-item status array; include error details for failed items; provide summary counts
408 Batch TimeoutSynchronous batch processing exceeded request timeoutSwitch to async processing for large batches; return 202 with status polling URL
Partial transaction failureDatabase transaction rolls back all items due to one failureUse savepoints for per-item isolation; or process items individually outside a wrapping transaction
Progress tracking staleWorker crashed mid-batch; progress stops updatingImplement heartbeat monitoring; mark batch as failed after heartbeat timeout; enable retry from last checkpoint

Refer to ${CLAUDE_SKILL_DIR}/references/errors.md for comprehensive error patterns.

Examples

Bulk user import: Accept a CSV-uploaded batch of 5000 user records via POST /batch/users/import, return 202 with batchId, process asynchronously with progress updates, and provide a downloadable results file when complete.

Multi-resource batch: Accept mixed operations in a single batch: [{method:"POST",path:"/users",...}, {method:"PUT",path:"/orders/123",...}, {method:"DELETE",path:"/products/456"}], executing each against the appropriate handler.

Idempotent batch retry: Client includes idempotencyKey per batch item; on retry, already-completed items return their cached result without re-execution, while failed items are re-attempted.

See ${CLAUDE_SKILL_DIR}/references/examples.md for additional examples.

Resources

svg-icon-generator

jeremylongshore

Svg Icon Generator - Auto-activating skill for Visual Content. Triggers on: svg icon generator, svg icon generator Part of the Visual Content skill category.

6814

d2-diagram-creator

jeremylongshore

D2 Diagram Creator - Auto-activating skill for Visual Content. Triggers on: d2 diagram creator, d2 diagram creator Part of the Visual Content skill category.

2312

performing-penetration-testing

jeremylongshore

This skill enables automated penetration testing of web applications. It uses the penetration-tester plugin to identify vulnerabilities, including OWASP Top 10 threats, and suggests exploitation techniques. Use this skill when the user requests a "penetration test", "pentest", "vulnerability assessment", or asks to "exploit" a web application. It provides comprehensive reporting on identified security flaws.

379

designing-database-schemas

jeremylongshore

Design and visualize efficient database schemas, normalize data, map relationships, and generate ERD diagrams and SQL statements.

978

performing-security-audits

jeremylongshore

This skill allows Claude to conduct comprehensive security audits of code, infrastructure, and configurations. It leverages various tools within the security-pro-pack plugin, including vulnerability scanning, compliance checking, cryptography review, and infrastructure security analysis. Use this skill when a user requests a "security audit," "vulnerability assessment," "compliance review," or any task involving identifying and mitigating security risks. It helps to ensure code and systems adhere to security best practices and compliance standards.

86

django-view-generator

jeremylongshore

Generate django view generator operations. Auto-activating skill for Backend Development. Triggers on: django view generator, django view generator Part of the Backend Development skill category. Use when working with django view generator functionality. Trigger with phrases like "django view generator", "django generator", "django".

15

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318398

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

451339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.