Skip to main content

Manage API Versions

The Speakeasy SDK provides both a global and per Api configuration option. If you want to use the SDK to track multiple Apis or Versions from the same service you can configure individual instances of the SDK.

import "github.com/speakeasy-api/speakeasy-go-sdk"

func main() {
r := mux.NewRouter()

// Configure a new instance of the SDK for the store API
storeSDKInstance := speakeasy.New(speakeasy.Config {
APIKey: "YOUR API KEY HERE", // retrieve from Speakeasy API dashboard.
ApiID: "store_api", // this is an ID you provide that you would like to associate captured requests with.
VersionID: "1.0.0", // this is a Version you provide that you would like to associate captured requests with.
})

// Configure a new instance of the SDK for the product API
productSDKInstance := speakeasy.New(speakeasy.Config {
APIKey: "YOUR API KEY HERE", // retrieve from Speakeasy API dashboard.
ApiID: "product_api", // this is an ID you provide that you would like to associate captured requests with.
VersionID: "1.0.0", // this is a Version you provide that you would like to associate captured requests with.
})

// The different instances of the SDK (with differnt IDs or even versions assigned) can be used to associate requests with different APIs and Versions.
s := r.PathPrefix("/store").Subrouter()
r.Use(storeSDKInstance.Middleware)

s := r.PathPrefix("/products").Subrouter()
r.Use(productSDKInstance.Middleware)
}