SDKs

Go SDK

Official Go client for the MUDBASE API.

Installation

bash
go get github.com/themudhaxk/mudbase-sdk/go
go get github.com/themudhaxk/mudbase-sdk/go

Quick Start

Construct an APIClient and call the resource you need — there is no unified client wrapper, each resource is its own *API field:

go
package main

import (
    "context"
    "os"

    mudbase "github.com/themudhaxk/mudbase-sdk/go"
)

func main() {
    configuration := mudbase.NewConfiguration()
    configuration.Servers = mudbase.ServerConfigurations{{URL: "https://cloud.mudbase.dev"}}
    ctx := context.WithValue(context.Background(), mudbase.ContextAPIKeys, map[string]mudbase.APIKey{
        "ApiKeyAuth": {Key: os.Getenv("MUDBASE_API_KEY")},
    })
    client := mudbase.NewAPIClient(configuration)

    // List documents in a collection
    items, _, err := client.DataAPI.ListData(ctx, projectID, collectionID).Execute()
    if err != nil {
        panic(err)
    }

    // Create a document
    body := map[string]interface{}{"name": "Morgan Chen"}
    created, _, err := client.DataAPI.CreateData(ctx, projectID, collectionID).Body(body).Execute()
    _ = created
}
package main

import (
    "context"
    "os"

    mudbase "github.com/themudhaxk/mudbase-sdk/go"
)

func main() {
    configuration := mudbase.NewConfiguration()
    configuration.Servers = mudbase.ServerConfigurations{{URL: "https://cloud.mudbase.dev"}}
    ctx := context.WithValue(context.Background(), mudbase.ContextAPIKeys, map[string]mudbase.APIKey{
        "ApiKeyAuth": {Key: os.Getenv("MUDBASE_API_KEY")},
    })
    client := mudbase.NewAPIClient(configuration)

    // List documents in a collection
    items, _, err := client.DataAPI.ListData(ctx, projectID, collectionID).Execute()
    if err != nil {
        panic(err)
    }

    // Create a document
    body := map[string]interface{}{"name": "Morgan Chen"}
    created, _, err := client.DataAPI.CreateData(ctx, projectID, collectionID).Body(body).Execute()
    _ = created
}

More

For installation in other languages, error handling, and pagination, see the SDKs Overview.