Magic for Go

Magic for Go

Reference for the Magic Admin SDK for Golang:


The Magic SDK for server-side Golang makes it easy to leverage Decentralized ID Tokens to authenticate your users for your app. This guide will cover some important topics for getting started with server-side APIs and to make the most of Magic's features.

  • Install the Magic Admin SDK to get started

  • View the API documentation below to learn the methods you'll be using

  • Go to Examples for an introduction to common patterns and use-cases


Looking for a client-side API instead? Check out:

👉 Magic Client SDK for web

👉 Magic Client SDK for React Native


The SDK requires Golang 1.13+ and Go Modules. To make sure your project is using Go Modules, you can look for go.mod file in your project's root directory. If it exits, then you are already using the Go Modules. If not, you can follow this guide to migrate to Go Modules.

Simply reference magic-admin-go in a Go program with an import of the SDK:

import ( ... "" ... )

Run any of the normal go commands (ex: build/install). The Go toolchain will take care of fetching the SDK automatically.

Alternatively, you can explicitly go get the package into a project:

go get

Creating an SDK Client Instance

The Client handles all the Magic API requests for your application. To instantiate:

package main import ( "" "" ) func main() { m := client.New("<YOUR_API_SECRET_KEY>", magic.NewDefaultClient()) userInfo, err := m.User.GetMetadataByToken("<DID_TOKEN>") ... }

Creating a Token Instance

The Token provides methods to interact with DID Token.

package main import ( "" "" ) func main() { tk, err := token.NewToken(did) if err != nil { return } if err := tk.Validate(); err != nil { return } ... }