Skip to content

trophyso/trophy-go

Repository files navigation

Go Library for Trophy

The Trophy Go client library provides convenient access to the Trophy API from applications written in Go.

Trophy provides APIs and tools for adding gamification to your application, keeping users engaged through rewards, achievements, streaks, and personalized communication.

Installation

Make sure your project is using Go Modules (it will have a go.mod file in its root if it already is):

go mod init

Then, reference trophy-go in a Go program with import:

import "github.com/trophy-so/trophy-go"

Alternatively, you can use go get:

go get github.com/trophy-so/trophy-go

Usage

package main

import (
	"github.com/trophyso/trophy-go"
	trophyclient "github.com/trophyso/trophy-go/client"
	"github.com/trophyso/trophy-go/option"

	"fmt"
	"context"
)

func main() {
	client := trophyclient.NewClient(
		option.WithApiKey("YOUR_API_KEY"),
	)

	email := "[email protected]"
	
	response, err := client.Metrics.Event(
		context.TODO(),
		"words-written",
		&api.MetricsEventRequest{
			User: &api.EventRequestUser{
				Id: "user-id",
				Email: &email,
			},
			Value: 750,
		},
	)

	if err != nil {
		fmt.Println(err)
		return
	}
	
	fmt.Println(response)
}

Documentation

See the Trophy API Docs for more information on the accessible endpoints.

License

This library is distributed under the MIT license found in the LICENSE file.

About

Go library for the Trophy API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages