πŸš€ Go-Tapd-SDK

by go-tapd

10 stars
368 downloads
Not rated
GitHub Website

About

The Go Tapd SDK is a Go client library for accessing the Tapd API

Details

Author
go-tapd
GitHub stars
10
Downloads
368
Categories
Developer Tools

- Go client library for the Tapd API
- Supports Basic Authentication and Personal Access Token (PAT)
- Provides service methods for labels, stories, and more
- Includes a webhook server for handling Tapd events
- Requires Go version 1.25 or later
- MIT licensed

Install with go get github.com/go-tapd/tapd. Create a client using either Basic Authentication (client ID + secret) or a Personal Access Token (PAT), then call service methods like LabelService.GetLabels or StoryService.GetStories. A webhook server can be built using the included webhook package to handle Tapd event dispatches.

πŸš€ Go-Tapd-SDK

Supported Go Versions
Package Version
GoDoc
codecov
Go Report Card
lint
tests
MIT license

The Go-Tapd-SDK is a Go client library for accessing the Tapd API.

> [!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.

🧰 Command Line Tool

> [!NOTE]
> 🧰 Prefer terminal or CI usage? Try the sibling project
> go-tapd/cli, a command line tool built on
> this SDK.
>
> βš™οΈ Use the CLI for quick local operations, shell scripts, and automation. See
> the repository for installation and usage examples.

πŸ“₯ Installation

go get github.com/go-tapd/tapd

✨ Features

see features.md

πŸ”§ Usage

API Service

- Example of using the Basic Authentication API service:

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:

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

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 for more information.

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.