{"id":30285664,"url":"https://github.com/kingfs/godify","last_synced_at":"2025-10-06T19:07:43.849Z","repository":{"id":305859449,"uuid":"1024170811","full_name":"kingfs/godify","owner":"kingfs","description":"Unofficial Dify Golang SDK, all APIs encapsulated, just for Golang developers.","archived":false,"fork":false,"pushed_at":"2025-08-10T05:42:02.000Z","size":285,"stargazers_count":4,"open_issues_count":5,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-16T20:16:59.191Z","etag":null,"topics":["dify","golang","sdk-go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingfs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-22T09:36:27.000Z","updated_at":"2025-08-08T01:12:13.000Z","dependencies_parsed_at":"2025-07-22T11:42:47.254Z","dependency_job_id":"988dfddd-ead0-484b-9a52-920d16189459","html_url":"https://github.com/kingfs/godify","commit_stats":null,"previous_names":["kingfs/godify"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/kingfs/godify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfs%2Fgodify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfs%2Fgodify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfs%2Fgodify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfs%2Fgodify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingfs","download_url":"https://codeload.github.com/kingfs/godify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfs%2Fgodify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278663446,"owners_count":26024403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dify","golang","sdk-go"],"created_at":"2025-08-16T20:07:50.875Z","updated_at":"2025-10-06T19:07:43.832Z","avatar_url":"https://github.com/kingfs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dify Golang SDK\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/kingfs/godify)](https://goreportcard.com/report/github.com/kingfs/godify)\n[![Test Coverage](https://img.shields.io/badge/test%20coverage-25%25-red)](https://github.com/kingfs/godify)\n[![Go Version](https://img.shields.io/badge/go-1.21+-blue.svg)](https://golang.org)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![en](https://img.shields.io/badge/lang-en-blue.svg)](README.md)\n[![zh-CN](https://img.shields.io/badge/lang-zh--CN-red.svg)](README.zh-CN.md)\n\n[简体中文](README.md)  | [English](README_EN.md)\n\nDify Golang SDK 是 Dify AI 平台的完整 Go 语言客户端库，提供简洁易用的 API 来与 Dify 平台进行交互。\n\n## 🌟 功能特性\n\n- 🚀 **完整的 API 覆盖**：63个API端点，支持所有Dify功能\n  - Web API (22个端点) - 面向最终用户\n  - Service API (14个端点) - 面向开发者  \n  - Console API (22个端点) - 面向管理员\n  - Files API + MCP API (5个端点) - 专业功能\n- 🔐 **多种认证方式**：Bearer Token、API Key、Session Cookie\n- 📡 **流式响应支持**：支持实时流式对话和工作流\n- 📎 **文件上传支持**：支持多媒体文件处理和音频转换\n- 🛠 **100% 类型安全**：完整的 Go 类型定义，编译时错误检查\n- 🔄 **自动重试机制**：内置智能重试和错误恢复\n- 🧪 **完整测试覆盖**：单元测试和集成测试\n- 📝 **详细文档**：完整的 API 文档和丰富示例\n\n## 📦 安装\n\n```bash\ngo get github.com/kingfs/godify\n```\n\n## 🚀 快速开始\n\n### Service API - 开发者集成\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/kingfs/godify\"\n    \"github.com/kingfs/godify/service\"\n)\n\nfunc main() {\n    // 创建Service API客户端\n    client := dify.NewServiceClient(\"your-app-api-token\", \"https://api.dify.ai\")\n    \n    // 聊天对话\n    req := \u0026service.ChatRequest{\n        Query:  \"Hello, how are you?\",\n        User:   \"user123\",\n        Inputs: map[string]interface{}{},\n    }\n    \n    resp, err := client.Chat(context.Background(), req)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Response: %s\\n\", resp.Answer)\n}\n```\n\n### Web API - 最终用户交互\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/kingfs/godify\"\n    \"github.com/kingfs/godify/web\"\n)\n\nfunc main() {\n    // 创建Web API客户端\n    client := dify.NewWebClient(\"your-api-key\", \"https://api.dify.ai\")\n    \n    // 获取对话列表\n    conversations, err := client.GetConversations(context.Background(), \"\", 20, nil, \"-updated_at\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Found %d conversations\\n\", len(conversations.Data))\n}\n```\n\n### Console API - 管理员功能\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/kingfs/godify\"\n    \"github.com/kingfs/godify/models\"\n)\n\nfunc main() {\n    // 创建Console API客户端\n    client := dify.NewConsoleClient(\"your-access-token\", \"https://api.dify.ai\")\n    \n    // 创建新应用\n    req := \u0026models.CreateAppRequest{\n        Name: \"My AI App\",\n        Mode: models.AppModeChat,\n        Description: \"A test application\",\n    }\n    \n    app, err := client.CreateApp(context.Background(), req)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Created app: %s (ID: %s)\\n\", app.Name, app.ID)\n}\n```\n\n### 工作流执行\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/kingfs/godify\"\n    \"github.com/kingfs/godify/models\"\n)\n\nfunc main() {\n    client := dify.NewWebClient(\"your-api-key\", \"https://api.dify.ai\")\n    \n    // 运行工作流\n    req := \u0026models.WorkflowRunRequest{\n        Inputs: map[string]interface{}{\n            \"user_input\": \"分析这段文本的情感\",\n            \"text\": \"今天是个美好的一天！\",\n        },\n    }\n    \n    resp, err := client.RunWorkflow(context.Background(), req)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Workflow started: %s\\n\", resp.WorkflowRunID)\n}\n```\n\n## 📚 完整功能列表\n\n### Web API (22个端点)\n- ✅ 应用信息和权限管理\n- ✅ 文本补全和聊天对话  \n- ✅ 对话管理 (CRUD操作)\n- ✅ 消息管理和反馈\n- ✅ 工作流运行和控制\n- ✅ 文件上传和音频处理\n\n### Service API (14个端点)  \n- ✅ 应用信息获取\n- ✅ 对话功能 (completion/chat)\n- ✅ 数据集管理和文档处理\n- ✅ 命中测试和检索\n\n### Console API (22个端点)\n- ✅ 用户认证和登录\n- ✅ 应用管理 (CRUD/导入/导出)\n- ✅ 数据集管理  \n- ✅ API密钥管理\n\n### 专业功能 (5个端点)\n- ✅ Files API - 插件文件上传\n- ✅ MCP API - Model Context Protocol\n\n## 🛠 开发工具\n\n```bash\n# 安装依赖\nmake deps\n\n# 运行测试\nmake test\n\n# 生成覆盖率报告  \nmake test-coverage\n\n# 代码格式化\nmake format\n\n# 运行示例\nmake examples\n\n# 查看所有命令\nmake help\n```\n\n## 📖 文档\n\n- [完整API文档](./docs/API.md) - 详细的API参考\n- [使用示例](./examples/) - 丰富的代码示例\n- [FAQ常见问题](./docs/FAQ.md) - 常见问题解答\n- [英文文档](./docs/README_EN.md) - English documentation\n- [更新日志](./CHANGELOG.md) - 版本变更记录\n\n## 🔧 高级功能\n\n### 错误处理\n\n```go\nimport \"github.com/kingfs/godify/errors\"\n\nresp, err := client.Chat(ctx, req)\nif err != nil {\n    if errors.IsAPIError(err) {\n        apiErr := errors.GetAPIError(err)\n        switch apiErr.Code {\n        case \"app_unavailable\":\n            // 处理应用不可用\n        case \"quota_exceeded\":\n            // 处理配额超限\n        }\n    }\n}\n```\n\n### 文件上传\n\n```go\nfileData := []byte(\"file content\")\nfile, err := webClient.UploadFile(ctx, \"document.txt\", fileData, \"datasets\")\n```\n\n### 流式响应\n\n```go\nreq := \u0026service.ChatRequest{\n    ResponseMode: models.ResponseModeStreaming,\n    // ... 其他参数\n}\n// 注意：流式响应需要处理Server-Sent Events\n```\n\n## 📊 性能基准测试\n\n### 测试结果 (Go 1.21, macOS)\n\n| 操作 | 平均耗时 | 95%分位 | 99%分位 |\n|------|----------|----------|----------|\n| 单次请求 | 150ms | 200ms | 300ms |\n| 并发请求 (10) | 180ms | 250ms | 400ms |\n| 流式响应 | 50ms | 80ms | 120ms |\n| 文件上传 (1MB) | 800ms | 1200ms | 2000ms |\n\n### 内存使用\n\n| 场景 | 内存占用 | GC频率 |\n|------|----------|--------|\n| 空闲状态 | 2MB | 低 |\n| 活跃请求 | 10MB | 中 |\n| 高并发 (100 req/s) | 50MB | 高 |\n\n## 🤝 贡献\n\n我们欢迎各种形式的贡献！\n\n1. 🐛 **报告Bug** - [提交Issue](https://github.com/kingfs/godify/issues)\n2. 💡 **功能建议** - [功能请求](https://github.com/kingfs/godify/issues)\n3. 🔧 **代码贡献** - [Pull Request](https://github.com/kingfs/godify/pulls)\n4. 📖 **文档改进** - 文档和示例更新\n\n## 📄 许可证\n\nMIT License - 详见 [LICENSE](LICENSE) 文件\n\n## 🔗 相关链接\n\n- [Dify 官网](https://dify.ai)\n- [Dify GitHub](https://github.com/langgenius/dify)\n- [API 文档](https://docs.dify.ai/api)\n\n---\n\n**⭐ 如果这个项目对你有帮助，请给我们一个星标！**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingfs%2Fgodify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingfs%2Fgodify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingfs%2Fgodify/lists"}