Skip to content

SDK for Buddy rest api written in GO

License

Notifications You must be signed in to change notification settings

buddy/api-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buddy SDK for Go

api-go-sdk is the Buddy SDK for the Go programming language.

The SDK requires a minimum version of Go 1.21.

Checkout out our blog for information about the latest changes

Getting started

To get started working with the SDK setup your project for Go modules, and retrieve the SDK dependencies with go get. This example shows how you can use the SDK to make an API request using the SDK's client.

Initialize Project
$ mkdir ~/buddytest
$ cd ~/buddytest
$ go mod init buddytest
Add SDK Dependencies
$ go get github.com/buddy/api-go-sdk
Write Code

In your preferred editor add the following content to main.go

package main

import (
  "fmt"
  "github.com/buddy/api-go-sdk/buddy"
  "os"
)

func main() {
  client, err := buddy.NewDefaultClient(os.Getenv("BUDDY_TOKEN"))
  if err != nil {
    fmt.Printf("Error: %s", err.Error())
    os.Exit(1)
  }
  profile, _, err := client.ProfileService.Get()
  if err != nil {
    fmt.Printf("Error: %s", err.Error())
    os.Exit(1)
  } else {
    fmt.Printf("My name is %s", profile.Name)
  }
}

Examples

For more examples go to examples directory

API docs

Full API docs can be found here