A SwitchBot API client for Golang
const (
openToken = "blahblahblah"
secretKey = "blahblahblah"
)
c := switchbot.New(openToken, secretKey)
// get physical devices and show
pdev, _, _ := c.Device().List(context.Background())
for _, d := range pdev {
fmt.Printf("%s\t%s\n", d.Type, d.Name)
}
To use SwitchBot API, you need to get Open Token for auth. Follow steps below:
- Download the SwitchBot app on App Store or Google Play Store
- Register a SwitchBot account and log in into your account
- Generate an Open Token within the app a) Go to Profile > Preference b) Tap App Version 10 times. Developer Options will show up c) Tap Developer Options d) Tap Get Token
- Roll up your sleeves and get your hands dirty with SwitchBot OpenAPI!