frappe-api-handler
FreeNo executable scriptsNot checkedCreate custom API endpoints and whitelisted methods for Frappe applications. Use when building REST APIs or custom endpoints.
by Venkateshvenki404224★ 29 GitHub starsAbout this skill
Frappe API Handler Skill
Create secure, efficient custom API endpoints for Frappe applications.
Global Rules
These Frappe conventions apply to everything this skill generates, and override any conflicting example below.
- Bench commands: use bare
bench(never./env/bin/benchor a full path). Always pass--site <site>explicitly — never run a barebench migrate/bench run-tests. Runbench startin the background and only if it isn't already running. Don't run discovery commands (which bench,bench --version). - DocType files live at
apps/<app>/<app>/<module>/doctype/<name>/<name>.json— the app name appears twice (directory + Python package) — with an empty__init__.pyalongside. Nevermkdirthe folder; write the JSON and runbench --site <site> migrateto create the structure. Don't addcreation,modified,owner,modified_by, ordocstatusas fields — Frappe manages them. - Database & ORM: prefer
frappe.qb.get_query()over rawfrappe.db.sql(). Usefrappe.db.get_all()for server logic (ignores permissions) andfrappe.db.get_list()for user-facing APIs (enforces them). Never usefrappe.db.set_value()on a field with validation or lifecycle logic — load the doc anddoc.save()so controller hooks run. Batch-fetch related records; never query inside a loop (N+1). - Never call
frappe.db.commit()in controllers, request handlers, background jobs, or patches — Frappe auto-commits on success and rolls back on uncaught errors. Flush manually only to make a write visible to a subsequentfrappe.enqueue()(or passenqueue_after_commit=True). - Permissions & APIs: put permission checks inside controller methods (enforced on every call path), not in API wrappers. Type-hint every
@frappe.whitelist()parameter so Frappe validates and casts it, and passmethods=[...]to pin the HTTP verb.
When to Use This Skill
Claude should invoke this skill when:
- User wants to create custom API endpoints
- User needs to whitelist Python methods for API access
- User asks about REST API implementation
- User wants to integrate external systems with Frappe
- User needs help with API authentication or permissions
Capabilities
1. Whitelisted Methods
Create Python methods accessible via API. Always type-hint parameters (Frappe validates and casts args by type hint, preventing type-confusion; without hints all args arrive as untrusted strings) and pin the HTTP verb with methods=[...]:
import frappe
from frappe import _
@frappe.whitelist(methods=["GET"])
def get_customer_details(customer_name: str):
"""Get customer details with validation"""
# Permission check (mirror the controller; keep checks on every call path)
if not frappe.has_permission("Customer", "read"):
frappe.throw(_("Not permitted"), frappe.PermissionError)
customer = frappe.get_doc("Customer", customer_name)
return {
"name": customer.name,
"customer_name": customer.customer_name,
"email": customer.email_id,
"phone": customer.mobile_no,
"outstanding_amount": customer.get_outstanding()
}
2. API Method Patterns
Public Methods (No Authentication):
@frappe.whitelist(allow_guest=True, methods=["GET"])
def public_api_method():
"""Accessible without login. Return only fields guests need — never leak
user emails, internal IDs, or permission-sensitive data."""
return {"message": "Public data"}
Authenticated Methods:
@frappe.whitelist(methods=["GET"])
def authenticated_method():
"""Requires valid session or API key"""
user = frappe.session.user
return {"user": user}
Permission-based Methods:
@frappe.whitelist(methods=["POST"])
def delete_customer(customer_name: str):
"""Check permissions before action"""
if not frappe.has_permission("Customer", "delete"):
frappe.throw(_("Not permitted"))
frappe.delete_doc("Customer", customer_name)
return {"message": "Customer deleted"}
3. REST API Endpoints
GET Request Handler: (use get_list for user-facing reads so DocType permissions are enforced)
@frappe.whitelist(methods=["GET"])
def get_items(filters: dict | None = None, fields: list | None = None, limit: int = 20):
"""Get list of items with filters"""
items = frappe.get_list(
"Item",
filters=filters or {},
fields=fields or ["name"],
limit=limit,
order_by="creation desc"
)
return {"items": items}
POST Request Handler:
@frappe.whitelist(methods=["POST"])
def create_sales_order(customer: str, items: list, delivery_date: str | None = None):
"""Create sales order from API. No frappe.db.commit() — Frappe commits POST on success."""
doc = frappe.get_doc({
"doctype": "Sales Order",
"customer": customer,
"delivery_date": delivery_date or frappe.utils.today(),
"items": items
Install frappe-api-handler in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the frappe-api-handler skill do?
Create custom API endpoints and whitelisted methods for Frappe applications. Use when building REST APIs or custom endpoints.
How do I install the frappe-api-handler skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the frappe-api-handler skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic