Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Bug report
description: The SDK sends, reads or does something wrong
labels:
- bug
body:
- type: checkboxes
attributes:
label: Self checks
options:
- label: I have searched existing issues, including closed ones.
required: true
- label: I am writing in English.
required: true
- type: input
attributes:
label: SDK version
description: The version in go.mod, or `dify.Version()`.
validations:
required: true
- type: input
attributes:
label: Dify version
description: "`dify.Probe(ctx, baseURL)` reports it, and every `*APIError` carries it."
validations:
required: true
- type: dropdown
attributes:
label: Cloud or self-hosted
options:
- Cloud
- Self-hosted
validations:
required: true
- type: textarea
attributes:
label: What happened, and what you expected
description: A minimal program that reproduces it, if you can. Leave out keys and tokens.
validations:
required: true
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: "\U0001F510 Security vulnerabilities"
url: https://github.com/langgenius/dify-go-sdk/security/advisories/new
about: Report vulnerabilities privately through GitHub Security Advisories, not in a public issue.
- name: "\U0001F41E A bug in Dify itself"
url: https://github.com/langgenius/dify/issues/new/choose
about: When the server misbehaves whichever client calls it, report it to Dify.
- name: "\U0001F4AC Questions and discussion"
url: https://github.com/langgenius/dify/discussions/categories/general
about: Ask for help and discuss with the Dify community.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Feature request
description: A Dify capability the SDK does not reach yet
labels:
- enhancement
body:
- type: textarea
attributes:
label: What you want to do
description: The task, and the Dify route or console action it needs, if you know it.
validations:
required: true
- type: textarea
attributes:
label: How you do it today
description: A workaround, the Python SDK, or the console.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

# The module has no dependencies beyond the standard library, so the workflows
# are the only thing to keep current.
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Summary

<!-- What changes, and why. Link the issue: `Fixes #123`. -->

## Checked against

<!-- Which Dify controller or payload model this follows, and whether the live
harness was run against a real Dify (`go test -run Live -v ./tests`). A mocked
server proves the request shape, nothing more. -->

## Checklist

- [ ] `gofmt -l .` and `go vet ./...` are clean, and `go test -race ./...` passes
- [ ] Each change has a test, named as a sentence
- [ ] User-visible changes are in CHANGELOG.md under "Unreleased"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/coverage.out
.env
.env.*
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

All notable changes to this project are recorded here. The project follows
[Semantic Versioning](https://semver.org/); while it is below 1.0, a minor
version may change the API.

## Unreleased

## v0.0.1 — 2026-09-28

The first release: a Go client for Dify, ported from the "using Dify" half of
[dify-python-sdk](https://github.com/langgenius/dify-python-sdk) and checked
against Dify 1.17.1.

### Added

- `App`, for one app's Service API: chat messages and conversations, workflow
runs and their events, completions, files, annotations, audio and
human-input forms. Streams are Go 1.23 iterators that accumulate a
`WorkflowRun` or `Message`.
- `Knowledge`, for the workspace's knowledge bases: datasets, documents,
segments, metadata, tags, retrieval settings, and RAG pipeline runs.
- `Management`, for the console API as an account: deploying apps (import,
publish, key) with each step reported on a `Deployment`, app keys and
triggers, Agents, knowledge pipelines, models, tools and plugins, skills,
and dataset keys. A login's session renews itself and ends with `Logout`.
- Retries that repeat a request only when that is safe, 429 handling that
honours Retry-After, stream idle timeouts, and errors classified by
`errors.Is` with the Dify version that answered.

Requires Go 1.24 or later. No dependencies beyond the standard library.
41 changes: 41 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Language Policy

To facilitate clear and effective communication, all discussions, comments, documentation, and pull requests in this project should be conducted in English. This ensures that all contributors can participate and collaborate effectively.
44 changes: 44 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Contributing to dify-go-sdk

Thanks for helping. Before changing anything, read [AGENTS.md](AGENTS.md): it
records how the package is laid out, the rules the code keeps, and the Dify
behaviours that each cost debugging time once. It is written for coding agents
and holds for people just as well.

## The short version

- **Dify's controllers are the specification** — not its docs, and not the
Python SDK. Read the route's pydantic query or payload model in
[langgenius/dify](https://github.com/langgenius/dify) under
`api/controllers/` before adding or changing a call, and say in the PR which
one you read.
- **A mocked server proves the request shape, nothing more.** A change to what
a call sends or reads should be run against a real Dify with the live
harness, and the PR should say whether it was.
- **Test names are sentences** describing the behaviour. When a test guards
something that was once broken, say so in it.
- **Comments say why, never what.**
- **No third-party dependencies.**

## Commands

```bash
go test -race ./... # offline; the live harness skips itself
gofmt -l . && go vet ./... # both must be clean

# against a running Dify (the harness creates and deletes everything it uses)
export DIFY_HOST=http://localhost DIFY_CONSOLE_EMAIL=… DIFY_CONSOLE_PASSWORD=…
go test -run Live -v ./tests
```

The live harness costs nothing to run: its fixture apps use template nodes,
not model nodes.

## Pull requests

Keep one change per pull request, with a test for it. Describe what you
checked against a real Dify and what you could not. Record user-visible
changes in [CHANGELOG.md](CHANGELOG.md) under "Unreleased".

All discussion, issues and pull requests are in English, following Dify's
[Code of Conduct](CODE_OF_CONDUCT.md).
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# dify-go-sdk

A Go client for Dify's Service API — running apps, and managing knowledge
bases. A port of the Service-API half of
[![Go Reference](https://pkg.go.dev/badge/github.com/langgenius/dify-go-sdk.svg)](https://pkg.go.dev/github.com/langgenius/dify-go-sdk)
[![CI](https://github.com/langgenius/dify-go-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/langgenius/dify-go-sdk/actions/workflows/ci.yml)

A Go client for [Dify](https://github.com/langgenius/dify) — running apps and
managing knowledge bases through the Service API, and deploying apps through
the console API. A port of the "using Dify" half of
[dify-python-sdk](https://github.com/langgenius/dify-python-sdk), verified
against Dify 1.17.1. Go 1.24+, no dependencies beyond the standard library.

The API may still change between 0.x releases; [CHANGELOG.md](CHANGELOG.md)
says what did.

```bash
go get github.com/langgenius/dify-go-sdk
```
Expand Down Expand Up @@ -247,10 +254,19 @@ engine) — Management deploys DSL text — and `OpenApiClient`.

```bash
go test -race ./... # offline
set -a; . ./.env; set +a # DIFY_HOST, DIFY_CONSOLE_EMAIL, DIFY_CONSOLE_PASSWORD
go test -run Live -v ./... # against a running Dify
export DIFY_HOST=… DIFY_CONSOLE_EMAIL=… DIFY_CONSOLE_PASSWORD=…
go test -run Live -v ./tests # against a running Dify
```

The live harness creates its apps and a dataset key through the console,
runs template-only workflows (no model cost), and deletes everything
afterwards. See [AGENTS.md](AGENTS.md).
afterwards. See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md).

## Security

Report vulnerabilities privately, as [SECURITY.md](SECURITY.md) describes —
not in a public issue.

## License

[MIT](LICENSE)
30 changes: 30 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Security Policy

## Reporting a vulnerability

If you believe you have found a security vulnerability in dify-go-sdk, please
report it privately through GitHub Security Advisories:

https://github.com/langgenius/dify-go-sdk/security/advisories/new

Please do not report security vulnerabilities through public issues,
discussions or pull requests.

Include as much as you can safely share: what the vulnerability is, how to
reproduce it, the SDK and Dify versions involved, and its potential impact.

A vulnerability in Dify itself, rather than in this client, belongs in
[Dify's own advisories](https://github.com/langgenius/dify/security/advisories/new).

## What this SDK holds

Two things here are credentials and deserve care in a report:

- **Service-API keys** (`app-…`, `dataset-…`), which a client holds and masks
wherever it is printed.
- **A console session**, held by `Management`. It is the credential to a whole
Dify account, since Dify offers nothing narrower; `Management.Logout` ends it.

## Supported versions

Only the latest release receives security fixes while the SDK is below 1.0.
Loading