{"id":13414018,"url":"https://github.com/bit4bit/gami","last_synced_at":"2025-12-30T18:31:57.982Z","repository":{"id":17022642,"uuid":"19786672","full_name":"bit4bit/gami","owner":"bit4bit","description":"GO - Asterisk AMI Interface","archived":true,"fork":false,"pushed_at":"2018-06-26T10:42:14.000Z","size":56,"stargazers_count":33,"open_issues_count":1,"forks_count":30,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:53:19.057Z","etag":null,"topics":["asterisk-ami","go","interface"],"latest_commit_sha":null,"homepage":"https://gitlab.com/bit4bit/gami","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bit4bit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-14T16:11:37.000Z","updated_at":"2024-02-26T00:53:43.000Z","dependencies_parsed_at":"2022-08-29T05:31:07.009Z","dependency_job_id":null,"html_url":"https://github.com/bit4bit/gami","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bit4bit%2Fgami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bit4bit%2Fgami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bit4bit%2Fgami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bit4bit%2Fgami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bit4bit","download_url":"https://codeload.github.com/bit4bit/gami/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243642066,"owners_count":20323953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asterisk-ami","go","interface"],"created_at":"2024-07-30T20:01:55.349Z","updated_at":"2025-12-18T00:09:48.797Z","avatar_url":"https://github.com/bit4bit.png","language":"Go","funding_links":[],"categories":["第三方API","Third-party APIs","第三方 APIs","第三方api","第三方API`第三方API 汇总`","\u003cspan id=\"第三方api-third-party-apis\"\u003e第三方API Third-party APIs\u003c/span\u003e","Utility"],"sub_categories":["查询语","HTTP Clients","Advanced Console UIs","Utility/Miscellaneous","高級控制台界面","Fail injection","实用程序/Miscellaneous","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流","高级控制台界面"],"readme":"GAMI\n====\n\nGO - Asterisk AMI Interface\n\ncommunicate with the  Asterisk AMI, Actions and Events.\n\nExample connecting to Asterisk and Send Action get Events.\n\n```go\npackage main\nimport (\n\t\"log\"\n\t\"github.com/bit4bit/gami\"\n\t\"github.com/bit4bit/gami/event\"\n\t\"time\"\n)\n\nfunc main() {\n\tami, err := gami.Dial(\"127.0.0.1:5038\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tami.Run()\n\tdefer ami.Close()\n\t\n\t//install manager\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\t//handle network errors\n\t\t\tcase err := \u003c-ami.NetError:\n\t\t\t\tlog.Println(\"Network Error:\", err)\n\t\t\t\t//try new connection every second\n\t\t\t\t\u003c-time.After(time.Second)\n\t\t\t\tif err := ami.Reconnect(); err == nil {\n\t\t\t\t\t//call start actions\n\t\t\t\t\tami.Action(\"Events\", gami.Params{\"EventMask\": \"on\"})\n\t\t\t\t}\n\t\t\t\t\n\t\t\tcase err := \u003c-ami.Error:\n\t\t\t\tlog.Println(\"error:\", err)\n\t\t\t//wait events and process\n\t\t\tcase ev := \u003c-ami.Events:\n\t\t\t\tlog.Println(\"Event Detect: %v\", *ev)\n\t\t\t\t//if want type of events\n\t\t\t\tlog.Println(\"EventType:\", event.New(ev))\n\t\t\t}\n\t\t}\n\t}()\n\t\n\tif err := ami.Login(\"admin\", \"root\"); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t\n\t\n\tif _, errPing := ami.Action(\"Ping\", nil); errPing != nil {\n\t\tlog.Fatal(errPing)\n\t}\n\t\n\t//async actions\n\trsPing, rsErr := ami.AsyncAction(\"Ping\", gami.Params{\"ActionID\": \"pingo\"})\n\tif rsErr != nil {\n\t\tlog.Fatal(rsErr)\n\t}\n\t\t\t\t\t\t\n\tif _, err := ami.Action(\"Events\", gami.Params{\"EventMask\":\"on\"}); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t\n\tlog.Println(\"ping:\", \u003c-rsPing)\n\t\n\n}\n```\n\n###TLS SUPPORT\nIn order to use TLS connection to manager interface you could `Dial` with additional parameters\n```go\n//without TLS\nami, err := gami.Dial(\"127.0.0.1:5038\")\n\n//if certificate is trusted\nami, err := gami.Dial(\"127.0.0.1:5039\", gami.UseTLS)\n\n//if self signed certificate\nami, err := gami.Dial(\"127.0.0.1:5039\", gami.UseTLS, gami.UnsecureTLS)\n\n//if custom tls configuration\nami, err := gami.Dial(\"127.0.0.1:5039\", gami.UseTLSConfig(\u0026tls.Config{}))\n```\n**WARNING:**\n*Only Asterisk \u003e=1.6 supports TLS connection to AMI and\nit needs additional configuration(follow the [Asterisk AMI configuration](http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/AMI-configuration.html) documentation)*\n\nCURRENT EVENT TYPES\n====\n\nThe events use documentation and struct from *PAMI*.\n\nuse **bit4bit/gami/event.New()** for get this struct from raw event\n\nEVENT ID          | TYPE TEST  \n----------------  | ---------- \n*Newchannel*      | YES\n*Newexten*        | YES\n*Newstate*        | YES \n*Dial*            | YES \n*ExtensionStatus* | YES \n*Hangup*          | YES \n*PeerStatus*      | YES\n*PeerEntry*\t      | YES\n*VarSet*          | YES \n*AgentLogin*      | YES\n*Agents*          | YES\n*AgentLogoff*     | YES\n*AgentConnect*    | YES\n*RTPReceiverStats* | YES\n*RTPSenderStats* | YES\n*Bridge* | YES\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbit4bit%2Fgami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbit4bit%2Fgami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbit4bit%2Fgami/lists"}