Generate code to integrate Frappe with external REST APIs. Use when connecting to third-party services, payment gateways, or external data sources.
Generates API client code to integrate Frappe with external REST APIs, handling authentication and errors.
/plugin marketplace add Venkateshvenki404224/frappe-apps-manager/plugin install frappe-apps-manager@frappe-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Generate robust API client code for integrating Frappe with external REST APIs, handling authentication, error recovery, and data transformation.
Claude should invoke this skill when:
REST API Client Template:
import requests
import frappe
from frappe import _
class ExternalAPIClient:
def __init__(self):
self.base_url = frappe.conf.get('external_api_url')
self.api_key = frappe.conf.get('external_api_key')
self.timeout = 30
def get_headers(self):
return {
'Authorization': f'Bearer {self.api_key}',
'Content-Type': 'application/json',
'User-Agent': 'Frappe/1.0'
}
def get(self, endpoint, params=None):
"""GET request with error handling"""
try:
response = requests.get(
f'{self.base_url}/{endpoint}',
params=params,
headers=self.get_headers(),
timeout=self.timeout
)
response.raise_for_status()
return response.json()
except requests.exceptions.Timeout:
frappe.throw(_('Request timeout'))
except requests.exceptions.HTTPError as e:
self._handle_http_error(e)
except Exception as e:
frappe.log_error(frappe.get_traceback(),
'External API Error')
frappe.throw(_('API request failed'))
def post(self, endpoint, data):
"""POST request"""
response = requests.post(
f'{self.base_url}/{endpoint}',
json=data,
headers=self.get_headers(),
timeout=self.timeout
)
response.raise_for_status()
return response.json()
def _handle_http_error(self, error):
"""Handle HTTP errors"""
status_code = error.response.status_code
if status_code == 401:
frappe.throw(_('API authentication failed'))
elif status_code == 404:
frappe.throw(_('Resource not found'))
elif status_code == 429:
frappe.throw(_('Rate limit exceeded'))
else:
frappe.throw(_(f'API error: {status_code}'))
OAuth 2.0 Flow:
def get_oauth_token():
"""Get OAuth access token with refresh"""
# Check cache first
token = frappe.cache().get_value('oauth_token:provider')
if token:
return token
# Get from settings
settings = frappe.get_single('OAuth Settings')
response = requests.post(
settings.token_url,
data={
'grant_type': 'client_credentials',
'client_id': settings.client_id,
'client_secret': settings.get_password('client_secret')
}
)
if response.status_code == 200:
token_data = response.json()
access_token = token_data['access_token']
# Cache token
frappe.cache().set_value(
'oauth_token:provider',
access_token,
expires_in_sec=token_data.get('expires_in', 3600) - 60
)
return access_token
frappe.throw(_('OAuth authentication failed'))
Frappe Integration Patterns:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.