{ "info": { "author": "ovsoil", "author_email": "huaxin.yu@atmatrix.org", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# pyatn-client\n\n**pyatn-client is Python ATN client, used to call DBot's API easily through payment channel**\n\n\n## Install\n\nPython ATN client depends on python3.6+, simply use pip3 to install, See [Installation](install.md) for detail.\n\n```bash\npip3 install pyatn-client\n```\n\n## Usage\n\n1. Use command `pyatn` to create an account and get some ATN if you don't have an account before.\n\n```bash\npyatn create-account\npyatn get-atn --address
\n```\n\n2. There are various DBots which provide AI API on our [AI Market](https://market-test.atnio.net). Here is an example, use [AI poetry](https://market-test.atnio.net/detail/0xfd4f504f373f0af5ff36d9fbe1050e6300699230) to write poetry.\n\n```python\nfrom pyatn_client import Atn\n\nDBOTADDRESS = '0xfd4F504F373f0af5Ff36D9fbe1050E6300699230' # address of the DBot you want to test, use 'AI poetry' as example\nURI = '/reg' # uri of the DBot's API endpoint which you want to call\nMETHOD = 'POST' # method of the DBot's API endpoint which you want to call\nrequests_kwargs = {\n \"data\": {\n \"theme\": \"\u4e2d\u79cb\u6708\u66f4\u5706\"\n }\n}\n\n# init Atn\natn = Atn(\n pk_file='',\n pw_file=''\n)\n\n# Call a DBot API 12 times\nfor i in range(12):\n response = atn.call_dbot_api(dbot_address=DBOTADDRESS,\n uri=URI,\n method=METHOD,\n **requests_kwargs)\n print('Call {}:\\n{}'.format(i + 1, response.text))\n\n# close the channel only when you do not need it any more,\n# the remain balance in the channel will be returned to your account\natn.close_channel(DBOTADDRESS)\n\n```\n\nIn the example above, channel will be auto created if no one between your account and the DBot, and will be topuped if the remain balance in the channel is not enough.\n\nThe deposit value is determined by `deposit_strategy`, which is a callable function with price of endpoint as input parameter. The default deposit value is 10 times the price of endpoint.\n\nThis behavior can be changed, You can pass in `deposit_strategy` when init class `Atn` or use `set_deposit_strategy` method to change it. It can be set `None` to disable auto create or topup the channel, then you should create or topup channel by yourself before call the `call_dbot_api` method. Here is an example.\n\n\n```python\nfrom pyatn_client import Atn\n\nDBOTADDRESS = '0xfd4F504F373f0af5Ff36D9fbe1050E6300699230' # address of the DBot you want to test\nURI = '/reg' # uri of the DBot's API endpoint which you want to call\nMETHOD = 'POST' # method of the DBot's API endpoint which you want to call\nrequests_kwargs = {\n \"data\": {\n \"theme\": \"\u4e2d\u79cb\u6708\u66f4\u5706\"\n }\n}\n\n# init Atn with deposit_strategy=None, it will disable auto create or topup channel.\natn = Atn(\n pk_file='',\n pw_file='',\n deposit_strategy=None, # disable auto create or topup channel\n)\n\n# get price of the endpoint to be called\nprice = atn.get_price(DBOTADDRESS, URI, METHOD)\n# open channel with the DBot, only one opened channel is allowed between two address\n# it will return the channel if one existed.\nchannel = atn.open_channel(DBOTADDRESS, 10 * price)\n# wait DBot server sync channel info with the blockchain\natn.wait_dbot_sync(DBOTADDRESS)\nif channel.deposit - channel.balance < price:\n atn.topup_channel(DBOTADDRESS, 10 * price)\n # wait DBot server sync channel info with the blockchain\n atn.wait_dbot_sync(DBOTADDRESS)\n\n# call DBot API 12 times\nfor i in range(12)\n print('Call {}:'.format(call_count))\n # AtnException will raise when eleventh call for insufficient balance, catch it in a production environment\n response = atn.call_dbot_api(dbot_address=DBOTADDRESS,\n uri=URI,\n method=METHOD,\n **requests_kwargs)\n print('Call {}:\\n{}'.format(i + 1, response.text))\n\n```\n\n## API Documentation\n\n[API Documentation](https://pyatn-client-doc.atnio.net)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ATNIO/pyatn-client", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyatn-client", "package_url": "https://pypi.org/project/pyatn-client/", "platform": "", "project_url": "https://pypi.org/project/pyatn-client/", "project_urls": { "Homepage": "https://github.com/ATNIO/pyatn-client" }, "release_url": "https://pypi.org/project/pyatn-client/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Python ATN Client", "version": "0.1.1" }, "last_serial": 4388736, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "686d267165c11cffe1b3abacfeb5c44e", "sha256": "c29cd56b8002c0140e2966f9c66db67318c580294c0b65d4a80618ccc32e1f8b" }, "downloads": -1, "filename": "pyatn-client-0.0.1.tar.gz", "has_sig": false, "md5_digest": "686d267165c11cffe1b3abacfeb5c44e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42348, "upload_time": "2018-09-26T12:47:54", "url": "https://files.pythonhosted.org/packages/bb/48/1cadddbd9e567a4fedacd67cbd545c4c0e67da38a20676bbe1451fc414fb/pyatn-client-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "42e41314eaff07e96339fc05cf776094", "sha256": "9547381d3ba448c768e5fd0f9df0e011998a56177d77be401a7a113eddf7563e" }, "downloads": -1, "filename": "pyatn-client-0.0.2.tar.gz", "has_sig": false, "md5_digest": "42e41314eaff07e96339fc05cf776094", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28016, "upload_time": "2018-09-26T13:13:08", "url": "https://files.pythonhosted.org/packages/ad/07/81c31862685b1094bdb17c4152a0b27832f7a55a8e3b2df9c99f3d89118e/pyatn-client-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "b19db8a835411ae089f00780730a3499", "sha256": "872cd574310743e0f3f6a67da14099d114da32a0be7681b539876020f47b04dd" }, "downloads": -1, "filename": "pyatn-client-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b19db8a835411ae089f00780730a3499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32188, "upload_time": "2018-09-27T00:36:15", "url": "https://files.pythonhosted.org/packages/a2/09/d06faf3a558a2e42f57c32054301ae36fa221dbbc333a10a1f39c5b76742/pyatn-client-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "42dd0f244131fbe5d3d1ac1ed7e3fa50", "sha256": "9cdc07905451d0499b15c7faefb16aa81bce062c89b55224f9efff8b3dc965ba" }, "downloads": -1, "filename": "pyatn-client-0.0.4.tar.gz", "has_sig": false, "md5_digest": "42dd0f244131fbe5d3d1ac1ed7e3fa50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34243, "upload_time": "2018-10-09T08:00:51", "url": "https://files.pythonhosted.org/packages/db/12/ba54922fca9d5c1af03202cf39c4d7e22873c9e289b4b91f3c0492f3516e/pyatn-client-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "3aab27de0fc1fabf2b90865763a1f368", "sha256": "c43ad7cf98a25ad9e6ba4e81de0b4a762a799dcec1601bcca861ef2d18cb9a50" }, "downloads": -1, "filename": "pyatn-client-0.0.5.tar.gz", "has_sig": false, "md5_digest": "3aab27de0fc1fabf2b90865763a1f368", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35263, "upload_time": "2018-10-11T07:48:42", "url": "https://files.pythonhosted.org/packages/91/ce/5924c24a83a1ee4ed3a78ff7d8e3b3d6a38ecd65c8560a529c173f9402ec/pyatn-client-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "e0a2426052538872e6fc38162f6f8821", "sha256": "df97d498c1d72f827a5539f8653b60022efe9fc3dcd79b5e720bb55148c349a0" }, "downloads": -1, "filename": "pyatn-client-0.0.6.tar.gz", "has_sig": false, "md5_digest": "e0a2426052538872e6fc38162f6f8821", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32838, "upload_time": "2018-10-11T08:16:43", "url": "https://files.pythonhosted.org/packages/e0/c2/657bf03506a38e6421faaec11883a95359dda0a563c3184fd47e9945e946/pyatn-client-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "d68b398fad61609f1e32bf3e669dda9a", "sha256": "0fab7d688d26bf2485050f7e2a3796daa032f2d976743325311eccde0c7c69ec" }, "downloads": -1, "filename": "pyatn-client-0.0.7.tar.gz", "has_sig": false, "md5_digest": "d68b398fad61609f1e32bf3e669dda9a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33059, "upload_time": "2018-10-11T12:25:31", "url": "https://files.pythonhosted.org/packages/33/44/bf8be8f042c25616667619925088696ef5c331e0030b75c04857922a884b/pyatn-client-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "177bac6b55dfa1a2cdf85dbf32fc04a3", "sha256": "1c6452f87c0d21307c91256f446f7cb1768c49600623c2a525225bb947d69747" }, "downloads": -1, "filename": "pyatn-client-0.0.8.tar.gz", "has_sig": false, "md5_digest": "177bac6b55dfa1a2cdf85dbf32fc04a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32299, "upload_time": "2018-10-12T09:41:15", "url": "https://files.pythonhosted.org/packages/10/99/d1c3157237910c10b23067a487ca8928ced50215a841bcaa5c0638837386/pyatn-client-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "97567850337ee6d75022e98cf5e0f261", "sha256": "f06cfe83b29bf9fe81324fbfe099b596f89b814823d0beb099ca8657165aa69e" }, "downloads": -1, "filename": "pyatn-client-0.0.9.tar.gz", "has_sig": false, "md5_digest": "97567850337ee6d75022e98cf5e0f261", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33056, "upload_time": "2018-10-15T03:08:20", "url": "https://files.pythonhosted.org/packages/9b/39/89735c51737512b4e6ee956833696d55943921a7f5e1db5c30f56db249a5/pyatn-client-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "4071e5e44f6de7adb0f300257f98f1e3", "sha256": "dcce0f0eaf4a332a9b9e95e15643b41ab151667c2d5b6a670ad749c8329ddd49" }, "downloads": -1, "filename": "pyatn-client-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4071e5e44f6de7adb0f300257f98f1e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32843, "upload_time": "2018-10-18T03:10:46", "url": "https://files.pythonhosted.org/packages/54/47/8521d927f12064a534294b95fb449d5873b1e67c45b8f326aedac752f619/pyatn-client-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f5d0bc36b34a592b064c76e6e9374a81", "sha256": "d18635de8e0c19bb1bb30da5785bfc7b0b1dee1a3a9ee32f0d21fc6273f1dc1c" }, "downloads": -1, "filename": "pyatn-client-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f5d0bc36b34a592b064c76e6e9374a81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32846, "upload_time": "2018-10-18T03:15:10", "url": "https://files.pythonhosted.org/packages/b1/a8/605c82996c69079576c7d90b3cb75610958159763e5effa0ea6270457ab3/pyatn-client-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f5d0bc36b34a592b064c76e6e9374a81", "sha256": "d18635de8e0c19bb1bb30da5785bfc7b0b1dee1a3a9ee32f0d21fc6273f1dc1c" }, "downloads": -1, "filename": "pyatn-client-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f5d0bc36b34a592b064c76e6e9374a81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32846, "upload_time": "2018-10-18T03:15:10", "url": "https://files.pythonhosted.org/packages/b1/a8/605c82996c69079576c7d90b3cb75610958159763e5effa0ea6270457ab3/pyatn-client-0.1.1.tar.gz" } ] }