{"id":13813974,"url":"https://github.com/ettoreleandrotognoli/python-ami","last_synced_at":"2025-04-05T03:12:03.612Z","repository":{"id":1642574,"uuid":"43763556","full_name":"ettoreleandrotognoli/python-ami","owner":"ettoreleandrotognoli","description":"Python AMI Client","archived":false,"fork":false,"pushed_at":"2024-05-14T11:56:09.000Z","size":162,"stargazers_count":115,"open_issues_count":18,"forks_count":70,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-29T02:08:39.799Z","etag":null,"topics":["ami","asterisk","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ettoreleandrotognoli.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-06T16:36:48.000Z","updated_at":"2025-03-04T13:51:27.000Z","dependencies_parsed_at":"2024-06-19T00:19:06.631Z","dependency_job_id":"03aaa524-f078-420e-afa9-7a3ab61516ee","html_url":"https://github.com/ettoreleandrotognoli/python-ami","commit_stats":{"total_commits":148,"total_committers":12,"mean_commits":"12.333333333333334","dds":"0.14189189189189189","last_synced_commit":"9922ccae5db73d0ee248942b8cfab9f939962024"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-ami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-ami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-ami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-ami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ettoreleandrotognoli","download_url":"https://codeload.github.com/ettoreleandrotognoli/python-ami/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["ami","asterisk","python"],"created_at":"2024-08-04T04:01:38.695Z","updated_at":"2025-04-05T03:12:03.591Z","avatar_url":"https://github.com/ettoreleandrotognoli.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"=================\nPython AMI Client\n=================\n\n.. image:: https://travis-ci.org/ettoreleandrotognoli/python-ami.svg?branch=master\n    :target: https://travis-ci.org/ettoreleandrotognoli/python-ami\n\n.. image:: https://codecov.io/gh/ettoreleandrotognoli/python-ami/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/ettoreleandrotognoli/python-ami\n\n.. image:: https://badge.fury.io/py/asterisk-ami.svg\n    :target: https://badge.fury.io/py/asterisk-ami\n\n.. image:: https://img.shields.io/pypi/dm/asterisk-ami.svg\n    :target: https://pypi.python.org/pypi/asterisk-ami#downloads\n    \n.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/maintainability\n   :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/maintainability\n   :alt: Maintainability\n   \n.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/test_coverage\n   :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/test_coverage\n   :alt: Test Coverage\n\n.. image:: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami/badge\n    :target: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami\n    :alt: CodeFactor\n\nA simple Python AMI client\n\nSee the `code of conduct \u003cCODE_OF_CONDUCT.md\u003e`_.\n\nInstall\n-------\n\nInstall asterisk-ami\n\n.. code-block:: shell\n\n    pip install asterisk-ami\n\nInstall latest asterisk-ami\n\n.. code-block:: shell\n\n    pip install git+https://github.com/ettoreleandrotognoli/python-ami\n\nUsage\n-----\n\n\nConnect\n~~~~~~~\n\n.. code-block:: python\n\n    from asterisk.ami import AMIClient\n    \n    client = AMIClient(address='127.0.0.1',port=5038)\n    client.login(username='username',secret='password')\n    \nDisconnect\n~~~~~~~~~~\n\n.. code-block:: python\n\n    client.logoff()\n\n\nSend an action\n~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    from asterisk.ami import SimpleAction\n    \n    action = SimpleAction(\n        'Originate',\n        Channel='SIP/2010',\n        Exten='2010',\n        Priority=1,\n        Context='default',\n        CallerID='python',\n    )\n    client.send_action(action)\n\n\nSend an action with adapter\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    from asterisk.ami import AMIClientAdapter\n    \n    adapter = AMIClientAdapter(client)\n    adapter.Originate(\n        Channel='SIP/2010',\n        Exten='2010',\n        Priority=1,\n        Context='default',\n        CallerID='python',\n    )\n    \nSynchronous Response\n~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    #without adapter\n    future = client.send_action(action)\n    response = future.response\n    \n    #with adapter\n    future = adapter.Originate(...)\n    response = future.response\n    \n\nAsynchronous Response\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    def callback_response(response):\n        print(response)\n\n    #without adapter\n    future = client.send_action(action,callback=callback_response)\n    \n    #with adapter\n    future = adapter.Originate(...,_callback=callback_response)\n    \n    #you can use the future to wait the callback execute\n    reponse = future.response\n\nListen Events\n~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    def event_listener(event,**kwargs):\n        print(event)\n\n    client.add_event_listener(event_listener)\n    \n\nFilter Events\n~~~~~~~~~~~~~\n\nWith a custom class\n\n.. code-block:: python\n\n    from asterisk.ami import EventListener\n\n    class RegistryEventListener(EventListener):\n    \n        def on_Registry(event,**kwargs):\n            print('Registry Event',event)\n            \n    client.add_event_listener(RegistryEventListener())\n    \n    class AllEventListener(EventListener):\n    \n        def on_event(event,**kwargs):\n            print('Event',event)\n    \n    client.add_event_listener(AllEventListener())\n\nWith black or white list\n\n.. code-block:: python\n\n    def event_listener(event,**kwargs):\n        print(event)\n        \n    client.add_event_listener(\n        event_listener, white_list=['Registry','PeerStatus']\n    )\n    \n    client.add_event_listener(\n        event_listener, black_list=['VarSet']\n    )\n            \nLike a custom class\n\n.. code-block:: python\n\n    def event_listener(event,**kwargs):\n        print(event)\n        \n    client.add_event_listener(\n        on_VarSet=event_listener,\n        on_ExtensionStatus=event_listener\n    )\n    \n    client.add_event_listener(\n        on_event=event_listener\n    )\n    \n\nFilter Event Value\n~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    def event_listener(event,**kwargs):\n        print('Ringing',event)\n        \n    \n    client.add_event_listener(\n        event_listener,\n        white_list='Newstate',\n        ChannelStateDesc='Ringing',\n        ConnectedLineNum='2004',\n    )\n    \nFilter with regex\n~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    import re\n    \n    def event_listener(event,**kwargs):\n        print(event)\n        \n    client.add_event_listener(\n        on_Newstate=event_listener,\n        white_list=re.compile('.*'),\n        ChannelStateDesc=re.compile('^Ring.*'),\n    )\n    \n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fettoreleandrotognoli%2Fpython-ami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fettoreleandrotognoli%2Fpython-ami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fettoreleandrotognoli%2Fpython-ami/lists"}