A Go SDK for the MongoDB Atlas API.
Note that atlas-sdk-go only supports the two most recent major versions of Go.
go get go.mongodb.org/atlas-sdk/v20250312026
Construct a new Atlas SDK client, then use the various services on the client to access different parts of the Atlas API. For example:
import "go.mongodb.org/atlas-sdk/v20250312026/admin"
func example() {
ctx := context.Background()
apiKey := os.Getenv("MONGODB_ATLAS_PUBLIC_KEY")
apiSecret := os.Getenv("MONGODB_ATLAS_PRIVATE_KEY")
sdk, err := admin.NewClient(admin.UseDigestAuth(apiKey, apiSecret))
if err != nil {
log.Fatalf("Error when instantiating new client: %v", err)
}
projects, response, err := sdk.ProjectsAPI.ListGroups(ctx).Execute()
if err != nil {
log.Fatalf("Could not fetch projects: %v", err)
}
fmt.Printf("Response status: %v\n", response.Status)
}For documentation about obtaining apiKey and apiSecret go to https://docs.atlas.mongodb.com/configure-api-access.
The services of a client divide the API into logical chunks and correspond to the structure of the Atlas API documentation at https://www.mongodb.com/docs/atlas/reference/api-resources-spec/.
The SDK provides an opt-in helper for tools to detect known AI agents that invoke them and add an identifier to their User-Agent:
import "go.mongodb.org/atlas-sdk/v20250312026/detectaiagent"
userAgent := "my-tool/1.0"
if agent, ok := detectaiagent.Detect(); ok {
userAgent += " " + agent.UserAgentIdentifier
// agent.ID can also be used for telemetry.
}
// pass userAgent to the SDK via admin.UseUserAgent(userAgent).Please refer to the docs
See examples
Testify Mock files are generated using Mockery to help to unit test clients using Atlas Go SDK.
See our CONTRIBUTING.md Guide.
atlas-sdk-go is released under the Apache 2.0 license. See LICENSE