goami2
AMI v2 library for Asterisk PBX
About goami2
goami2: Simple Asterisk Manager Interface (AMI) library
Go library that provides interface to Asteris AMI. The library uses given net.Conn (tcp or tls), login
and starts reading AMI messages from connection and parse them into *Message object.
Provides simple interface to send messages to AMI.
It uses re2c to create very fast protocol parser. Run "make bench" for benchmark tests.
Usage example:
import (
"errors"
"fmt"
"log"
"net"
"github.com/staskobzar/goami2"
)
func main() {
conn, err := net.Dial("tcp", "asterisk.host:5038")
if err != nil {
log.Fatalln(err)
}
// login and create client
client, err := goami2.NewClient(conn, "admin", "pa55w0rd")
if err != nil {
log.Fatalln(err)
}
log.Println("client connected and logged in")
// create AMI Action message and send to the asterisk.host
msg := goami2.NewAction("CoreStatus")
msg.AddActionID()
client.Send(msg.Byte())
defer client.Close() // close connections and all channels
for {
select {
case msg := <-client.AllMessages():
log.Printf("Got message: %s\n", msg.JSON())
case err := <-client.Err():
// terminate on network closed
if errors.Is(err, goami2.ErrEOF) {
log.Fatalf("Connection error: %s", err)
}
log.Printf("WARNING: AMI client error: %s", err)
}
}
}
Docs
See documentation at https://pkg.go.dev/github.com/staskobzar/goami2
Frequently Asked Questions
What is goami2?
goami2 is a Third-party APIs library for the Go programming language. AMI v2 library for Asterisk PBX
How do I install goami2?
Install goami2 with the Go module system using `go get staskobzar/goami2`. Check the repository for the current installation instructions.
What category does goami2 belong to?
goami2 is listed under Third-party APIs, specifically Third-party APIs.