frappe-api
БесплатноБез исполняемых скриптовНе проверенFrappe Python and JavaScript API reference including document operations, database queries, utilities, and REST API patterns. Use when working with…
Об этом скилле
Frappe API Reference
Complete reference for Frappe's Python and JavaScript APIs for document operations, database queries, utilities, and server communication.
When to Use This Skill
- Working with Document API (get_doc, new_doc, save)
- Database operations (frappe.db.*)
- Making API calls from client to server
- Using Frappe utilities (date, number formatting)
- Creating whitelisted API endpoints
- Working with REST API
Python API
Document Operations
Get Document
# Get existing document
doc = frappe.get_doc("Customer", "CUST-001")
# Get document with filters
doc = frappe.get_doc("Customer", {"customer_name": "John"})
# Get last document
doc = frappe.get_last_doc("Customer", filters={"status": "Active"})
# Get cached document (read-only, faster)
doc = frappe.get_cached_doc("Customer", "CUST-001")
# Check if document exists
if frappe.db.exists("Customer", "CUST-001"):
doc = frappe.get_doc("Customer", "CUST-001")
Create Document
# Create new document
doc = frappe.new_doc("Customer")
doc.customer_name = "New Customer"
doc.customer_type = "Company"
doc.insert()
# Create with dict
doc = frappe.get_doc({
"doctype": "Customer",
"customer_name": "New Customer",
"customer_type": "Company"
})
doc.insert()
# Create and insert in one step
doc = frappe.get_doc({
"doctype": "Customer",
"customer_name": "New Customer"
}).insert()
# Insert ignoring permissions
doc.insert(ignore_permissions=True)
# Insert ignoring mandatory fields
doc.insert(ignore_mandatory=True)
Update Document
# Update and save
doc = frappe.get_doc("Customer", "CUST-001")
doc.customer_name = "Updated Name"
doc.save()
# Save ignoring permissions
doc.save(ignore_permissions=True)
# Update single value
frappe.db.set_value("Customer", "CUST-001", "customer_name", "New Name")
# Update multiple values
frappe.db.set_value("Customer", "CUST-001", {
"customer_name": "New Name",
"status": "Active"
})
# Bulk update
frappe.db.set_value("Customer", {"status": "Inactive"}, "status", "Active")
Delete Document
# Delete document
frappe.delete_doc("Customer", "CUST-001")
# Delete ignoring permissions
frappe.delete_doc("Customer", "CUST-001", ignore_permissions=True)
# Delete with linked documents
frappe.delete_doc("Customer", "CUST-001", force=True)
# Delete from controller
doc.delete()
Database API (frappe.db)
Select Queries
# Get single value
value = frappe.db.get_value("Customer", "CUST-001", "customer_name")
# Get multiple fields
values = frappe.db.get_value("Customer", "CUST-001",
["customer_name", "status"], as_dict=True)
# Get with filters
value = frappe.db.get_value("Customer",
{"customer_type": "Company"}, "customer_name")
# Get list of values
names = frappe.db.get_all("Customer",
filters={"status": "Active"},
fields=["name", "customer_name"],
order_by="creation desc",
limit=10
)
# Get list with pluck (single field as list)
names = frappe.db.get_all("Customer",
filters={"status": "Active"},
pluck="name"
)
# Complex filters
docs = frappe.db.get_all("Sales Invoice",
filters={
"status": ["in", ["Paid", "Unpaid"]],
"grand_total": [">", 1000],
"posting_date": ["between", ["2024-01-01", "2024-12-31"]],
"customer": ["like", "%Corp%"]
},
fields=["name", "customer", "grand_total"]
)
# Filter operators
# =, !=, <, >, <=, >=
# in, not in
# like, not like
# between
# is, is not (for None)
# descendants of, ancestors of (for tree doctypes)
# Get count
count = frappe.db.count("Customer", {"status": "Active"})
# Check existence
exists = frappe.db.exists("Customer", "CUST-001")
exists = frappe.db.exists("Customer", {"customer_name": "John"})
Raw SQL
# Execute SQL query
result = frappe.db.sql("""
SELECT name, customer_name, grand_total
FROM `tabSales Invoice`
WHERE status = %s AND grand_total > %s
ORDER BY creation DESC
LIMIT 10
""", ("Paid", 1000), as_dict=True)
# Single value
total = frappe.db.sql("""
SELECT SUM(grand_total) FROM `tabSales Invoice`
WHERE status = 'Paid'
""")[0][0]
# With named parameters
result = frappe.db.sql("""
SELECT * FROM `tabCustomer`
WHERE name = %(name)s
""", {"name": "CUST-001"}, as_dict=True)
Insert/Update
# Insert raw
frappe.db.sql("""
INSERT INTO `tabCustomer` (name, customer_name)
VALUES (%s, %s)
""", ("CUST-002", "New Customer"))
# Commit transaction
frappe.db.commit()
# Rollback
frappe.db.rollback()
Whitelisted API
# Create API endpoint
@frappe.whitelist()
def get_customer_details(customer):
"""Get customer details
Args:
customer: Customer ID
Returns:
dict: Customer details
"""
doc = frappe.get_doc("Customer", customer)
return {
"name": doc.name,
"customer_name": doc.customer_name,
"outstanding_amount": get_outstanding(customer)
Установить frappe-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл frappe-api?
Frappe Python and JavaScript API reference including document operations, database queries, utilities, and REST API patterns. Use when working with frappe.get_doc, frappe.db, frappe.call, or any Frappe API methods.
Как установить скилл frappe-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frappe-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic