# README
go-lwApi
LiquidWeb API Golang client
Setting up Authentication
When creating an api client, it expects to be configured via a configuration struct. Here is an example of how to get an api client.
package main
import (
"fmt"
lwApi "github.com/liquidweb/go-lwApi"
)
func main() {
config := lwApi.LWAPIConfig{
Username: "ExampleUsername",
Password: "ExamplePassword",
Url: "api.liquidweb.com",
}
apiClient, iErr := lwApi.New(&config)
}
Importing
import (
lwApi "github.com/liquidweb/go-lwApi"
)
Calling a method
apiClient, iErr := lwApi.New(&config)
if iErr != nil {
panic(iErr)
}
args := map[string]interface{}{
"uniq_id": "2UPHPL",
}
got, gotErr := apiClient.Call("bleed/asset/details", args)
if gotErr != nil {
panic(gotErr)
}
fmt.Printf("RETURNED:\n\n%+v\n\n", got)
As you can see, you don't need to prefix the params
key, as that is handled in the Call()
function for you.
# Functions
New takes a *LWAPIConfig, and gives you a *Client.
# Structs
A Client holds the packages *LWAPIConfig and *http.Client.
A LWAPIConfig holds the configuration details used to call the API with the client.
A LWAPIError is used to identify error responses when JSON unmarshalling json from a byte slice.
# Interfaces
LWAPIRes is a convenient interface used (for example) by CallInto to ensure a passed struct knows how to indicate whether or not it had an error.