https://github.com/go-tapd/tapd
The Go Tapd SDK is a Go client library for accessing the Tapd API
https://github.com/go-tapd/tapd
golang library sdk tapd tapd-webhook webhook
Last synced: 2 months ago
JSON representation
The Go Tapd SDK is a Go client library for accessing the Tapd API
- Host: GitHub
- URL: https://github.com/go-tapd/tapd
- Owner: go-tapd
- License: mit
- Created: 2024-08-21T00:54:34.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2026-04-04T04:46:27.000Z (2 months ago)
- Last Synced: 2026-04-04T06:32:40.813Z (2 months ago)
- Topics: golang, library, sdk, tapd, tapd-webhook, webhook
- Language: Go
- Homepage: https://github.com/go-tapd/tapd
- Size: 917 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
# 🚀 Go-Tapd-SDK

[](https://github.com/go-tapd/tapd/releases)
[](https://pkg.go.dev/github.com/go-tapd/tapd)
[](https://codecov.io/gh/go-tapd/tapd)
[](https://goreportcard.com/report/github.com/go-tapd/tapd)
[](https://github.com/go-tapd/tapd/actions/workflows/lint.yml)
[](https://github.com/go-tapd/tapd/actions/workflows/test.yml)
[](https://opensource.org/licenses/MIT)
The Go-Tapd-SDK is a Go client library for accessing the [Tapd API](https://www.tapd.cn/).
> [!WARNING]
> This is currently still a non-stable version, is not recommended for production use.
If you encounter any issues, you are welcome to [submit an issue](https://github.com/go-tapd/tapd/issues/new).
## 📥 Installation
```bash
go get github.com/go-tapd/tapd
```
## ✨ Features
see [features.md](features.md)
## 🔧 Usage
### API Service
- Example of using the Basic Authentication API service:
```go
package main
import (
"context"
"log"
"github.com/go-tapd/tapd"
)
func main() {
client, err := tapd.NewClient("client_id", "client_secret")
if err != nil {
log.Fatal(err)
}
// example: get labels
labels, _, err := client.LabelService.GetLabels(context.Background(), &tapd.GetLabelsRequest{
WorkspaceID: tapd.Ptr(123456),
})
if err != nil {
log.Fatal(err)
}
log.Printf("labels: %+v", labels)
}
```
- Example of using the Personal Access Token (PAT) API service:
```go
package main
import (
"context"
"log"
"github.com/go-tapd/tapd"
)
func main() {
client, err := tapd.NewPATClient("your_access_token")
if err != nil {
log.Fatal(err)
}
// example: get stories
stories, _, err := client.StoryService.GetStories(context.Background(), &tapd.GetStoriesRequest{
WorkspaceID: tapd.Ptr(123456),
})
if err != nil {
log.Fatal(err)
}
log.Printf("stories: %+v", stories)
}
```
### Webhook Server Example
```go
package main
import (
"context"
"log"
"net/http"
"github.com/go-tapd/tapd/webhook"
)
type StoreUpdateListener struct{}
func (l *StoreUpdateListener) OnStoryUpdate(ctx context.Context, event *webhook.StoryUpdateEvent) error {
log.Printf("StoreUpdateListener: %+v", event)
return nil
}
func main() {
dispatcher := webhook.NewDispatcher(
webhook.WithRegisters(&StoreUpdateListener{}),
)
dispatcher.Registers(&StoreUpdateListener{})
srv := http.NewServeMux()
srv.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) {
log.Println("Received webhook request")
if err := dispatcher.DispatchRequest(r); err != nil {
log.Println(err)
}
w.Write([]byte("ok"))
})
http.ListenAndServe(":8080", srv)
}
```
## 📜 License
The MIT License (MIT). Please see [License File](LICENSE) for more information.