freeagent-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFreeAgent API Orchestration Skill
FreeAgent API编排技能
FreeAgent is an online accounting system for freelancers and small businesses. This skill provides intelligent navigation to FreeAgent API resources and orchestrates common workflows.
FreeAgent是面向自由职业者和小企业的在线会计系统。本技能提供对FreeAgent API资源的智能导航,并编排常见工作流。
Quick Reference: Which Resource Do I Need?
快速参考:我需要哪个资源?
| Task | Load Resource | API Domains |
|---|---|---|
| Set up OAuth, manage tokens, test API | | OAuth 2.0, token management |
| Create/update contacts, manage clients/suppliers | | Contacts, companies, users |
| Manage invoices, projects, expenses, timeslips | | Core financial entities |
| Bank accounts, transactions, reconciliation | | Banking, cash flow |
| Error handling, rate limits, retries, caching | | Production patterns |
| Common workflows, code examples, integration tips | | Real-world usage |
| All endpoints (reference only) | | Complete API reference |
| 任务 | 加载资源 | API领域 |
|---|---|---|
| 设置OAuth、管理令牌、测试API | | OAuth 2.0, 令牌管理 |
| 创建/更新联系人、管理客户/供应商 | | 联系人、公司、用户 |
| 管理发票、项目、费用、工时记录 | | 核心财务实体 |
| 银行账户、交易、对账 | | 银行业务、现金流 |
| 错误处理、速率限制、重试、缓存 | | 生产环境模式 |
| 常见工作流、代码示例、集成技巧 | | 实际场景使用 |
| 所有端点(仅作参考) | | 完整API参考 |
Orchestration Protocol
编排协议
Phase 1: Task Analysis
阶段1:任务分析
Identify what the user needs:
By Resource Type:
- Authentication issue? →
authentication-setup.md - Managing contacts/clients? →
contacts-organizations.md - Financial data (invoices, expenses, projects)? →
accounting-objects.md - Banking/reconciliation? →
banking-financial.md - Error or production concern? →
advanced-patterns.md - Practical example needed? →
examples.md
By HTTP Method:
- GET: List or retrieve → check relevant domain resource
- POST: Create → load resource file, check required fields
- PUT: Update → load resource file, verify patch fields
- DELETE: Remove → check resource-specific constraints
确定用户需求:
按资源类型:
- 认证问题? →
authentication-setup.md - 管理联系人/客户? →
contacts-organizations.md - 财务数据(发票、费用、项目)? →
accounting-objects.md - 银行业务/对账? →
banking-financial.md - 错误或生产环境相关问题? →
advanced-patterns.md - 需要实用示例? →
examples.md
按HTTP方法:
- GET:列出或检索 → 查看相关领域资源
- POST:创建 → 加载资源文件,检查必填字段
- PUT:更新 → 加载资源文件,验证补丁字段
- DELETE:删除 → 检查资源特定约束
Phase 2: Resource Navigation
阶段2:资源导航
Load the appropriate resource file and:
- Find the endpoint section (e.g., "Contacts", "Invoices", "Bank Accounts")
- Review required/optional parameters
- Check request and response formats
- Use provided curl or Python examples
For template code: (bash) or (Python)
templates/api-request-template.shtemplates/python-client.py加载合适的资源文件并执行以下操作:
- 找到端点章节(如“联系人”“发票”“银行账户”)
- 查看必填/可选参数
- 检查请求和响应格式
- 使用提供的curl或Python示例
模板代码:(bash)或(Python)
templates/api-request-template.shtemplates/python-client.pyPhase 3: Execution & Validation
阶段3:执行与验证
Before API call:
- Verify authentication is set up (check if needed)
authentication-setup.md - Validate required fields are present
- Format dates as ISO 8601 (YYYY-MM-DD) and timestamps (YYYY-MM-DDTHH:MM:SSZ)
- Use correct resource URLs (e.g., )
https://api.freeagent.com/v2/contacts/123
During API call:
- Use templates as starting points
- Monitor rate limit headers:
X-RateLimit-Remaining - Implement retry logic for 429 errors (see )
advanced-patterns.md
After API call:
- Check response status code
- Parse JSON response (resource name is top-level key)
- Apply error handling patterns if needed
API调用前:
- 确认已完成认证设置(如有需要,查看)
authentication-setup.md - 验证必填字段是否存在
- 日期格式化为ISO 8601(YYYY-MM-DD),时间戳格式化为(YYYY-MM-DDTHH:MM:SSZ)
- 使用正确的资源URL(如)
https://api.freeagent.com/v2/contacts/123
API调用中:
- 以模板为起点
- 监控速率限制头:
X-RateLimit-Remaining - 为429错误实现重试逻辑(查看)
advanced-patterns.md
API调用后:
- 检查响应状态码
- 解析JSON响应(资源名称为顶级键)
- 如有需要,应用错误处理模式
Quick Start: Authentication
快速开始:认证
- Create OAuth app: https://dev.freeagent.com/
- Get authorization code:
https://api.freeagent.com/v2/approve_app?client_id=YOUR_ID - Exchange for tokens at
https://api.freeagent.com/v2/token_endpoint - Store in environment variables: ,
FREEAGENT_ACCESS_TOKENFREEAGENT_REFRESH_TOKEN - Include in every request:
Authorization: Bearer $FREEAGENT_ACCESS_TOKEN
→ See Authentication & Setup for detailed walkthrough
- 创建OAuth应用:https://dev.freeagent.com/
- 获取授权码:
https://api.freeagent.com/v2/approve_app?client_id=YOUR_ID - 在交换令牌
https://api.freeagent.com/v2/token_endpoint - 存储到环境变量:,
FREEAGENT_ACCESS_TOKENFREEAGENT_REFRESH_TOKEN - 在每个请求中包含:
Authorization: Bearer $FREEAGENT_ACCESS_TOKEN
→ 查看认证与设置获取详细步骤
API Domain Overview
API领域概述
Production URL:
Sandbox URL: (test without affecting production)
https://api.freeagent.com/v2/https://api.sandbox.freeagent.com/v2/| Domain | Primary Endpoints | Use Case |
|---|---|---|
| Authentication | | OAuth flows, token refresh |
| Contacts & Organizations | | Client/supplier management |
| Accounting Objects | | Core financial workflow |
| Banking & Financial | | Cash flow, reconciliation |
Rate Limits: 120 requests/minute, 3600 requests/hour
Response Format: JSON with resource wrapper (e.g., or )
{"contact": {...}}{"contacts": [...]}生产环境URL:
沙箱URL: (测试时不影响生产环境)
https://api.freeagent.com/v2/https://api.sandbox.freeagent.com/v2/| 领域 | 主要端点 | 使用场景 |
|---|---|---|
| 认证 | | OAuth流程、令牌刷新 |
| 联系人和组织 | | 客户/供应商管理 |
| 会计对象 | | 核心财务工作流 |
| 银行业务与财务 | | 现金流、对账 |
速率限制: 120次请求/分钟,3600次请求/小时
响应格式: 带资源包装的JSON(如或)
{"contact": {...}}{"contacts": [...]}Common HTTP Patterns
常见HTTP模式
| Operation | Method | Example |
|---|---|---|
| List items | GET | |
| Get one item | GET | |
| Create item | POST | |
| Update item | PUT | |
| Delete item | DELETE | |
| Filter results | GET params | |
| 操作 | 方法 | 示例 |
|---|---|---|
| 列出项目 | GET | |
| 获取单个项目 | GET | |
| 创建项目 | POST | |
| 更新项目 | PUT | |
| 删除项目 | DELETE | |
| 过滤结果 | GET参数 | |
Templates & Code Examples
模板与代码示例
Bash/cURL Template:
templates/api-request-template.sh- Flexible curl template for any endpoint
- GET/POST/PUT/DELETE support
- Header and parameter configuration
Python Client:
templates/python-client.py- Reusable FreeAgentClient class
- Error handling and rate limit support
- Convenience methods for common resources
Practical Examples:
resources/examples.md- Real-world workflows (create invoice, log timeslip, etc.)
- Python code patterns with the client class
- Error handling examples
- Bulk operations (import/export)
Bash/cURL模板:
templates/api-request-template.sh- 适用于任意端点的灵活curl模板
- 支持GET/POST/PUT/DELETE
- 头部和参数配置
Python客户端:
templates/python-client.py- 可复用的FreeAgentClient类
- 支持错误处理和速率限制
- 常见资源的便捷方法
实用示例:
resources/examples.md- 实际场景工作流(创建发票、记录工时等)
- 基于客户端类的Python代码模式
- 错误处理示例
- 批量操作(导入/导出)
Resource Files Summary
资源文件摘要
| File | Lines | Focus |
|---|---|---|
| ~180 | OAuth setup, token management, security |
| ~250 | Contact CRUD, bulk operations, company info |
| ~350 | Invoices, projects, expenses, timeslips, pagination |
| ~250 | Bank accounts, transactions, reconciliation, categories |
| ~350 | Error handling, rate limits, retries, caching, validation |
| ~400 | Practical code examples, integration patterns |
| ~300 | Complete API reference (use for quick lookup) |
| 文件 | 行数 | 重点 |
|---|---|---|
| ~180 | OAuth设置、令牌管理、安全 |
| ~250 | 联系人增删改查、批量操作、公司信息 |
| ~350 | 发票、项目、费用、工时记录、分页 |
| ~250 | 银行账户、交易、对账、分类 |
| ~350 | 错误处理、速率限制、重试、缓存、验证 |
| ~400 | 实用代码示例、集成模式 |
| ~300 | 完整API参考(用于快速查询) |
Troubleshooting Quick Links
故障排查快速链接
401 Unauthorized → Authentication Setup
422 Validation Error → Advanced Patterns
429 Rate Limit → Advanced Patterns
Specific Endpoint Help → Check relevant domain resource file above
Remember: Load only the resource file(s) you need for the current task. Start with the Quick Reference table above to identify which resource contains your answer.
401 未授权 → 认证设置
422 验证错误 → 进阶模式
429 速率限制 → 进阶模式
特定端点帮助 → 查看上方相关领域的资源文件
注意: 仅加载当前任务所需的资源文件。先通过上方的快速参考表格确定哪个资源包含你需要的答案。