{"id":21565148,"url":"https://github.com/cfware/ami","last_synced_at":"2025-03-18T05:17:33.220Z","repository":{"id":57177275,"uuid":"221894885","full_name":"cfware/ami","owner":"cfware","description":"Asterisk Manager Interface","archived":false,"fork":false,"pushed_at":"2020-05-18T19:23:12.000Z","size":172,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T11:44:45.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/cfware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-11-15T09:54:25.000Z","updated_at":"2021-08-30T18:48:32.000Z","dependencies_parsed_at":"2022-09-14T02:21:30.938Z","dependency_job_id":null,"html_url":"https://github.com/cfware/ami","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cfware","download_url":"https://codeload.github.com/cfware/ami/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244160055,"owners_count":20408021,"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":[],"created_at":"2024-11-24T10:18:35.430Z","updated_at":"2025-03-18T05:17:33.190Z","avatar_url":"https://github.com/cfware.png","language":"JavaScript","readme":"# ami [![NPM Version][npm-image]][npm-url]\n\n\u003e Astersik Manager Interface\n\n## class AMISocket\n\n```js\nimport AMISocket from 'ami';\n\nconst ami = new AMISocket();\n```\n\n### new AMISocket(options)\n\nConstruct a new AMI connection instance.  Default options:\n```js\n{\n  connect: {\n    host: 'localhost',\n    port: 5038\n  },\n  credentials: {\n    username: 'local',\n    secret: 'local'\n  },\n  events: true\n}\n```\n\n### AMISocket#amiVersion\n\nVersion string provided by the Asterisk server, example `2.10.5`.\nThis property is `undefined` prior to receiving first line from connected\nsocket.\n\n### AMISocket#connected\n\nBoolean value if the socket is connected.\n\n### AMISocket#authenticated\n\nBoolean value if the socket is authenticated.\n\n### async AMISocket#connect()\n\nConnect to the AMI server for this instance.  Promise is resolved once authentication is\nsuccessful.  Rejection occurs if connection or authentication fails.\n\nThis function resolves after queued packets are sent but before responses are received.\n\n### AMISocket#disconnect()\n\nDisconnect from the AMI server.  No attempt is made to wait for responses to requests that\nare in progress.\n\n### async AMISocket#send(object, options)\n### async AMISocket#getList(object, options)\n\n`object` is the key/value pairs to send as an AMI request.  This must contain an `action` key.\nA key can be specified multiple times by providing an array, for example:\n```js\nami.send({\n  action: 'originate',\n  // channel / app / etc\n  variable: [\n    'CHANVAR1=value',\n    'CHANVAR2=value'\n  ]\n});\n```\n\n`options.ignoreResponse` can be set to `true` if you don't care about the result.  In this\ncase the promise resolves as soon as the request is written to the socket.\n\n`options.responseType` controls the information provided when resolving:\n* `response`: resolves with a single object structured like the input object.  This is default for `AMISocket#send`.\n* `responses`: resolves with an array of objects.  This is default for `AMISocket#getList`.\n* `responsePacket`: resolves with a single `AMIPacket` instance.\n* `responsePackets`: resolves with an array of `AMIPacket` instances.\n\nKeys of all responses are normalized to lowercase strings.\n\n#### AMIPacket#asObject\n\nThis is the property which resolve requests that used `responseType` of `response` or `responses`.\n\n#### AMIPacket#values\n\nAn ordered array of name/value pairs, for example:\n```js\n[\n  ['actionid', 'random-generated-id'],\n  ['response', 'success']\n]\n```\n\nThis is only needed to deal with responses which violate the AMI specification.  An example\nof this is the `app_queue` [QueueRule](https://github.com/asterisk/asterisk/blob/2e7866ebb7773fdd4f67e80f3747e41d84bcb93b/apps/app_queue.c#L9744-L9777)\nresponse, see [ASTERISK-27072](https://issues.asterisk.org/jira/browse/ASTERISK-27072).\n\n#### AMIPacket#toString()\n\nThis is used internally to produce the raw data.  It could also be used for debug output.\nNote that keys are already tranformed to lowercase.\n\n[npm-image]: https://img.shields.io/npm/v/ami.svg\n[npm-url]: https://npmjs.org/package/ami\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcfware%2Fami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fami/lists"}