{ "info": { "author": "Ben Homnick", "author_email": "bhomnick@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Security", "Topic :: Security :: Cryptography", "Topic :: Software Development", "Topic :: System :: Monitoring" ], "description": "factom-api\n==========\n\nThis library provides Python clients for interacting with the factomd\nand factom-walletd APIs. While not all API methods have been implemented\nyet, you'll find most of what you need to build a working application\nare available, along with shortcut methods for accomplishing common\ntasks involving multiple calls between the wallet and daemon.\n\nBecause Python 2 is reaching EOL, this API client (from version 1.0.0\nonwards) targets Python 3.5 and higher.\n\nIf you're unfamiliar with Factom, I encourage you to `read the\ndocumentation `__, especially the `white\npaper `__.\nIn a nutshell, Factom provides a layer on top of the Bitcoin blockchain\nmaking it possible to secure data faster and in larger amounts than the\nBitcoin network would allow alone.\n\nGetting started\n---------------\n\nInstalling the API client\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe easiest way to install is directly from pip:\n\n::\n\n $ pip install factom-api\n\nUsage\n-----\n\nI'll go over a few common operations here you'll most likely use in\napplications. In general you'll need instances of both the wallet and\nfactomd clients to build and submit transactions. To build new clients:\n\n.. code:: python\n\n from factom import Factomd, FactomWalletd\n\n # Default settings\n factomd = Factomd()\n walletd = FactomWalletd()\n\n # You can also specify default fct and ec addresses, change host, or specify RPC credentials, for example:\n fct_address = 'FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q'\n ec_address = 'EC2jhmCtabeTXGtuLi3AaPzvwSuqksdVsjfxXMXV5gPmipXc4GjC'\n\n factomd = Factomd(\n host='http://someotherhost:8088',\n fct_address=fct_address,\n ec_address=ec_address,\n username='rpc_username',\n password='rpc_password'\n )\n\nTransacting factoids to factoids\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFirst let's query the balance in both of our fct addresses:\n\n.. code:: python\n\n >>> fct_address1 = 'FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q'\n >>> fct_address2 = 'FA3TMQHrCrmLa4F9t442U3Ab3R9sM1gThYMDoygPEVtxrbHtFRtg'\n >>> ec_address = 'EC2jhmCtabeTXGtuLi3AaPzvwSuqksdVsjfxXMXV5gPmipXc4GjC'\n\n # Initialize the two clients\n >>> factomd = Factomd()\n >>> walletd = FactomWalletd()\n\n # Query the balance in our first address. There should be a large amount\n >>> factomd.factoid_balance(fct_address1)\n {'balance': 1999999735950}\n\n # The second address should be empty.\n >>> factomd.factoid_balance(fct_address2)\n {'balance': 0}\n\nThe wallet client provides a shorcut method ``fct_to_fct()`` which\nperforms all the API calls needed to submit a simple fct to fct\ntransaction. This includes adding inputs and outputs, calculating the\nfee, building the signed transaction, and submitting it to the network.\n\n.. code:: python\n\n >>> walletd.fct_to_fct(factomd, 50000, fct_to=fct_address2, fct_from=fct_address1)\n {'message': 'Successfully submitted the transaction', 'txid': 'a4d641f13d82b1d1682549d44fa41c7e1b01f1a16f8cbddb5c695df53fcebfd7'}\n\nThe server reports the transaction was submitted and if we wait a few\nseconds we can see the results:\n\n.. code:: python\n\n >>> factomd.factoid_balance(fct_address2)\n {'balance': 50000}\n\nConverting factoids to entry credits\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nOur new entry credit address should have a balance of zero:\n\n.. code:: python\n\n >>> factomd.entry_credit_balance(ec_address)\n {'balance': 0}\n\nFirst, we need to ask for the conversion rate:\n\n.. code:: python\n\n >>> factomd.entry_credit_rate()\n {'rate': 1000}\n\nThis tells us we'll need to burn 1000 factoids in exchange for 1 entry\ncredit, so let's purchase 50 entry credits for 50000 factoids. Similar\nto ``fct_to_fct()``, the wallet client also provides a ``fct_to_ec()``\nshortcut for building and submitting simple fct conversion transactions.\n\n.. code:: python\n\n >>> walletd.fct_to_ec(factomd, 50000, fct_address=fct_address1, ec_address=ec_address)\n {'message': 'Successfully submitted the transaction', 'txid': 'd70b14ce05a21dbf772d1894383694b4537e17454915fc42dc20f02c1e0e2df2'}\n\nAnd if we query our entry credit balance we see the conversion has\nhappened:\n\n.. code:: python\n\n >>> factomd.entry_credit_balance(ec_address)\n {'balance': 50}\n\nWriting chains and entries\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe real meat and potatoes is the ability to easily read from and write\ndata to the blockchain. Let's write some test data. The wallet client\nprovides a ``new_chain()`` shortcut method that handles the API calls\nand encoding needed for creating a new chain. You could also build the\ntransaction manually if you'd like more control over each step, but for\nmost cases this is going to be easier.\n\n.. code:: python\n\n >>> walletd.new_chain(factomd, ['random', 'chain', 'id'], 'chain_content', ec_address=ec_address)\n {'message': 'Entry Reveal Success', 'entryhash': 'f9662a4675f4bb6566337eafd8237ab9fd2ba396947dadeb677c0526d367a5ce', 'chainid': 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495'}\n\nIf we wait a few minutes and search for the chain ID in the explorer we\ncan see our initial entry:\n\n.. figure:: screenshots/chain.png\n :alt: Our new chain\n\n Our new chain\n\nNow let's add another entry to the same chain:\n\n.. code:: python\n\n >>> chain_id = 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495'\n >>> walletd.new_entry(factomd, chain_id, ['random', 'entry', 'id'], 'entry_content', ec_address=ec_address)\n {'message': 'Entry Reveal Success', 'entryhash': '96f0472c9ec8a76c861fb4df37beb742938f41bbe492dc04893337bf387b83c5', 'chainid': 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495'}\n\nYou should see the new entry appear shortly.\n\nReading entries\n~~~~~~~~~~~~~~~\n\nIf the entries in your chain reference each other, you may want to scan\nthe entire chain in order to verify its integrity. The factomd client\nprovides a ``read_chain()`` method which iterates over all\nentry-containing blocks and returns a list of entries in reverse order.\n\n.. code:: python\n\n >>> chain_id = 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495'\n >>> factomd.read_chain(chain_id)\n [{'chainid': 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495', 'extids': ['random', 'entry', 'id'], 'content': 'entry_content'}, {'chainid': 'da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495', 'extids': ['random', 'chain', 'id'], 'content': 'chain_content'}]\n\nYou can see the two entries we created earlier.\n\nError handling\n~~~~~~~~~~~~~~\n\nWhen things go badly, API methods will raise a\n``factom.exceptions.FactomAPIError`` with details about the error.\n\n.. code:: python\n\n >>> walletd.new_chain(factomd, ['random', 'chain', 'id'], 'chain_content', ec_address=ec_address)\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"/src/factom/client.py\", line 196, in new_chain\n 'ecpub': ec_address or self.ec_address\n File \"/src/factom/client.py\", line 56, in _request\n handle_error_response(resp)\n File \"/src/factom/exceptions.py\", line 18, in handle_error_response\n raise codes[code](message=message, code=code, data=data, response=resp)\n factom.exceptions.InvalidParams: -32602: Invalid params\n\nMore data about the error is attached to the exception instance:\n\n.. code:: python\n\n >>> try:\n ... walletd.new_chain(factomd, ['random', 'chain', 'id'], 'chain_content', ec_address=ec_address)\n ... except FactomAPIError as e:\n ... print(e.data)\n ... \n Chain da2ffed0ae7b33acc718089edc0f1d001289857cc27a49b6bc4dd22fac971495 already exists\n\nIf you'd like to catch more specific errors, there are exception\nsubclasses for the different error codes returned by the APIs. See\n`factom/exceptions.py `__ for a list.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/FactomProject/factom-api", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "factom-api", "package_url": "https://pypi.org/project/factom-api/", "platform": "OS Independent", "project_url": "https://pypi.org/project/factom-api/", "project_urls": { "Homepage": "https://github.com/FactomProject/factom-api" }, "release_url": "https://pypi.org/project/factom-api/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Python client library for the Factom API", "version": "1.0.3" }, "last_serial": 5837286, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "41592d6d064079c8b0dde7a430c0bf1a", "sha256": "91243c8e59e0a5f13ace7899d3032edb1f2069e05edd29a9f149c5e1caa2654a" }, "downloads": -1, "filename": "factom_api-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "41592d6d064079c8b0dde7a430c0bf1a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 17828, "upload_time": "2017-12-15T12:24:53", "url": "https://files.pythonhosted.org/packages/a1/b9/58f199dfece6360baceb732987b1266bcac92e15ec2baf926c035acba638/factom_api-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4fe0606348126e5bfb109bf1e747eb14", "sha256": "2984ccdc85c0f7c9a4e0132750f0d133f50d03e98f355a48dedee90c65fc10ed" }, "downloads": -1, "filename": "factom_api-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "4fe0606348126e5bfb109bf1e747eb14", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 18006, "upload_time": "2017-12-15T12:27:46", "url": "https://files.pythonhosted.org/packages/ac/11/735fb00d4b9023551dfad34b68a8360e3d849d1852cf2eb40445bb045376/factom_api-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "61c06273fe7f207c56be68a3dcbd43ed", "sha256": "7d70d9610d5b709f58e49c02b29989e7fe25ddc87873d564f40dcade16225c94" }, "downloads": -1, "filename": "factom-api-0.1.0.tar.gz", "has_sig": false, "md5_digest": "61c06273fe7f207c56be68a3dcbd43ed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 193176, "upload_time": "2017-12-15T12:24:56", "url": "https://files.pythonhosted.org/packages/ac/58/87e2152831dd45735bb33e2c0ff18203794da9f1a58000047a33822304e8/factom-api-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "fa8ec3eca71155a141df1a7c562d41ad", "sha256": "740baa52fffc30063cc9fd61cb79939ee564b8dc7f0ccfae7b4aee2b7af1c6e8" }, "downloads": -1, "filename": "factom_api-0.1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "fa8ec3eca71155a141df1a7c562d41ad", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 18084, "upload_time": "2017-12-15T12:46:11", "url": "https://files.pythonhosted.org/packages/ac/62/2407a543699b4626e2223323bfcfa3c889d0661134481d7ddc3cd886ddd1/factom_api-0.1.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc23fe1eeeb9afd27baff5d94d737ef7", "sha256": "ae26e343a786b4edae6fab9ac09f6535f474e7c647602a216f67ff9b48cabdba" }, "downloads": -1, "filename": "factom-api-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fc23fe1eeeb9afd27baff5d94d737ef7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 193497, "upload_time": "2017-12-15T12:46:14", "url": "https://files.pythonhosted.org/packages/ab/85/5c136dc7e2daecd86b97dd7b115afbb7e6c7962673d7726c159333bfb08f/factom-api-0.1.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "abb592bcd005401a6446e1c0281eeefe", "sha256": "50f6292d83394b7bfe090e8abae4b911778d1357a30256d12b4419f7eeb0368e" }, "downloads": -1, "filename": "factom_api-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "abb592bcd005401a6446e1c0281eeefe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17486, "upload_time": "2019-07-30T14:45:41", "url": "https://files.pythonhosted.org/packages/dc/d9/1190b011b94882fdf73d22b2356b4c4391fae69374d347eb29dba14f9085/factom_api-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "91e5309385d6667b76464e78423868a0", "sha256": "f6c151db2f1a0e4bc78e2f57c1b672a05b8de75e6756b86d2a38f4db4f4e06c9" }, "downloads": -1, "filename": "factom-api-1.0.0.tar.gz", "has_sig": false, "md5_digest": "91e5309385d6667b76464e78423868a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 193380, "upload_time": "2019-07-30T14:45:43", "url": "https://files.pythonhosted.org/packages/93/f2/0284d2dff2077581231d98c0212576950a65a0646ad5d1788512ab68b611/factom-api-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "385cd236a8dde439949f9ca4cdce029c", "sha256": "680c702fe109f7bfeb7c59f4d4a69c02c591fc81b82976a75dcaef6295dc89ff" }, "downloads": -1, "filename": "factom_api-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "385cd236a8dde439949f9ca4cdce029c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17578, "upload_time": "2019-08-13T14:52:59", "url": "https://files.pythonhosted.org/packages/44/2b/92c5ab8739a2dbd3139a917a5225cc939f4b4e7f5efb7e4739a4dff82485/factom_api-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7f02e3f143a273a829ec88eef0f1496d", "sha256": "12729281b9b0549e0ea365dc94340f7ca10cd70853d960109bd8006d5d08c5a0" }, "downloads": -1, "filename": "factom-api-1.0.1.tar.gz", "has_sig": false, "md5_digest": "7f02e3f143a273a829ec88eef0f1496d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 193707, "upload_time": "2019-08-13T14:53:00", "url": "https://files.pythonhosted.org/packages/71/35/41f54c498aef23a9df75c283895ac817d137ed55ae909e50cab301a83de5/factom-api-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "1143322d2cadc6b8238d94714566be01", "sha256": "54f1ff0e065af0b6ccc87c56fd0dd8a71bc6691a58cefcf318e9c35bd250120a" }, "downloads": -1, "filename": "factom_api-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "1143322d2cadc6b8238d94714566be01", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17899, "upload_time": "2019-08-20T13:58:00", "url": "https://files.pythonhosted.org/packages/25/b1/e4e43f27dbfc60e7c43d8de7c4fb483c4316d1bb8b0417d9c675e1c8d85b/factom_api-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "367000f8f8a49fdf9455d078c9a5ecac", "sha256": "8c4a7891e1eba5b016894922402e28107283c9938e5e6a365da47b04b419f219" }, "downloads": -1, "filename": "factom-api-1.0.2.tar.gz", "has_sig": false, "md5_digest": "367000f8f8a49fdf9455d078c9a5ecac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 194099, "upload_time": "2019-08-20T13:58:01", "url": "https://files.pythonhosted.org/packages/03/35/d677e2583c07123123bf1f3a0d4e6452b82e7c5daedee94c428b0d6c6174/factom-api-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "e76d2c64424d26372e5522be73e8d560", "sha256": "9dcb97235a08fda8ae4966f7bcf77fffcbd8a1d37118467325741d9a4f8460a4" }, "downloads": -1, "filename": "factom-api-1.0.3.tar.gz", "has_sig": false, "md5_digest": "e76d2c64424d26372e5522be73e8d560", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 194168, "upload_time": "2019-09-16T16:55:17", "url": "https://files.pythonhosted.org/packages/5b/6d/97652b9cf44f39b6b809f5588e1d07bf5a8d47731a765a9508f86dd8a438/factom-api-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e76d2c64424d26372e5522be73e8d560", "sha256": "9dcb97235a08fda8ae4966f7bcf77fffcbd8a1d37118467325741d9a4f8460a4" }, "downloads": -1, "filename": "factom-api-1.0.3.tar.gz", "has_sig": false, "md5_digest": "e76d2c64424d26372e5522be73e8d560", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 194168, "upload_time": "2019-09-16T16:55:17", "url": "https://files.pythonhosted.org/packages/5b/6d/97652b9cf44f39b6b809f5588e1d07bf5a8d47731a765a9508f86dd8a438/factom-api-1.0.3.tar.gz" } ] }