Skip to main content

Accessing the API from Go

For Go, we offer the mittwald API client library github.com/mittwald/api-client-go. This library is an auto-generated client for the mStudio v2 (and any subsequent) API and can be installed via go get.

Quickstart

Install this package using go get:

$ go get github.com/mittwald/api-client-go

Then, import the version-specific client in your project:

import "github.com/mittwald/api-client-go/mittwaldv2"

To use the client, invoke the mittwaldv2.New constructor, and configure it using the proved option methods:

  1. Omit authentication option for unauthenticated access
  2. mittwaldv2.WithAccessToken (recommended) to authenticate with an API token
  3. mittwaldv2.WithAccessTokenFromEnv (recommended) to authenticate with an API token that is automatically retrieved from the process environment variables (MITTWALD_API_TOKEN).
  4. mittwaldv2.WithUsernamePassword to authenticate with username and password; this does not work for users that have 2FA enabled
  5. mittwaldv2.WithAccessTokenRetrievalKey to authenticate with an access token retrieval key (only relevant for mStudio extensions)
  6. mittwaldv2.WithExtensionSecret to authenticate as an extension (only relevant for mStudio extensions)

Have a look at our API introduction for more information on how to obtain an API token and how to get started with the API.

Further reading

For a complete documentation, have a look at the libraries README file or the automatically generated package documentation.