{ "info": { "author": "jarhill0", "author_email": "jarhill0@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "hnpy\n====\n\n*a Hacker News API wrapper written in Python*\n\n|Build Status| |Coverage Status|\n\n--------------\n\nPurpose\n-------\n\nThis was written with the goal of sticking close to the API in terms of\nnaming and structure, but with the added benefits that come with using\nPython objects.\n\nInstallation\n------------\n\nUse one of the following, depending on how your system is configured:\n\n.. code:: shell\n\n pip install hnpy\n pip3 install hnpy\n python3 -m pip install hnpy\n\nUsage\n-----\n\nCreate an instance of the main class like this:\n\n.. code:: python\n\n import hnpy\n\n hn = hnpy.HackerNews()\n\nItems\n~~~~~\n\nIf you know an item\u2019s ID, you can access it like this:\n\n.. code:: python\n\n post = hn.item(8863)\n\nAn Item can be one of five types: \u201cjob\u201d, \u201cstory\u201d, \u201ccomment\u201d, \u201cpoll\u201d, or\n\u201cpollopt.\u201d You can determine its type by accessing ``post.type``.\n\nItem objects are loaded lazily, meaning they only make network requests\nwhen information that they don\u2019t already have is needed.\n\nItems can be checked for equality against other Items or against the ID\nin ``int`` or ``str`` form.\n\nItems have various attributes which depend on their type. You can use\n``hasattr()`` to programmatically determine whether a certain Item has\nan attribute or not. More on attributes\n`here `__. Attribute names in\nhnpy are copied from field names in the API.\n\nItems have five special attributes:\n\n+-----------------------------------+-----------------------------------+\n| Attribute name | Explanation |\n+===================================+===================================+\n| content | The \u201cmeat\u201d of the Item \u2014 |\n| | ``text``, ``url``, or ``title``, |\n| | with a fallback to an empty |\n| | string if none exist. |\n+-----------------------------------+-----------------------------------+\n| link | URL to access the Item. |\n+-----------------------------------+-----------------------------------+\n| parent | Item that this one replies to |\n| | (not always present). |\n+-----------------------------------+-----------------------------------+\n| poll | Item of type ``poll`` that this |\n| | one belongs to (only present on |\n| | ``pollopt`` Items). |\n+-----------------------------------+-----------------------------------+\n| by | User who created this Item. |\n+-----------------------------------+-----------------------------------+\n\nThe ``link`` and ``content`` attributes are noted here because the API\ndoes not directly provide them, so they are not documented elsewhere.\nThe ``parent``, ``poll`` and ``by`` attributes are noted because they\ncontain fully-featured, lazily-loaded Items as opposed to just the IDs\nthat the API responds with. The rest of an Items attributes are\ndelivered in the same format that they are received from the API.\n\nThe attributes can be accessed like so:\n\n.. code:: python\n\n post.content\n post.link\n post.parent\n post.poll\n post.by\n\nItems also have 2 special methods which iterate and deliver Items. Each\ntakes an optional ``limit=`` parameter which defaults to 25.\n\n+-----------------------------------+-----------------------------------+\n| Method name | Use |\n+===================================+===================================+\n| kids() | Iterate over the comments that |\n| | reply to this Item. |\n+-----------------------------------+-----------------------------------+\n| parts() | Iterate over the options of this |\n| | Item (only present on ``poll`` |\n| | types). |\n+-----------------------------------+-----------------------------------+\n\nThe methods can be used like this:\n\n.. code:: python\n\n for kid in post.kids(limit=5):\n print(kid.content)\n for opt in post.parts():\n print(opt.content)\n\nListings\n~~~~~~~~\n\nYou can use hnpy to view the following listings provided by Hacker News:\n\n- Top (this is the view shown on the homepage of Hacker News)\n- Best\n- New\n- Ask HN Stories\n- Show HN Stories\n- Job Stories\n\nJust like the special methods of an Item, these methods of a HackerNews\nobject take an optional ``limit=`` parameter. They iterate over the\nspecified listing, yielding lazy Items as they go.\n\nExample:\n\n.. code:: python\n\n for post in hn.best(limit=5):\n print(post.link)\n\nThe method names are:\n\n- ``top()``\n- ``best()``\n- ``new()``\n- ``ask()``\n- ``show()``\n- ``jobs()``\n\nUsers\n~~~~~\n\nA User can be created from a user\u2019s name using the ``HackerNews.user()``\nmethod:\n\n.. code:: python\n\n user = hn.user('jl')\n\nBesides the attributes `noted in the Hacker News API\ndocumentation `__, Users\ncontain the following attributes and methods:\n\n+-----------------------------------+-----------------------------------+\n| Attribute/method name | Purpose |\n+===================================+===================================+\n| link | A URL to view the User\u2019s profile |\n| | online. |\n+-----------------------------------+-----------------------------------+\n| submitted() | Iterate over Items created by the |\n| | user, with optional ``limit=`` |\n| | parameter. |\n+-----------------------------------+-----------------------------------+\n\nMisc\n~~~~\n\nThe HackerNews object has a method ``updates()`` which returns an\nUpdates object, which has iterating methods just like those of other\nobjects (optional ``limit=`` parameter, objects yielded) which give the\nmost recently changed item and profiles (more info\n`here `__).\nIts two methods are ``items()`` and ``profiles()``.\n\nThe HackerNews object also has a method ``max_item()`` which returns a\nlazy version of the newest Item.\n\nCredits\n-------\n\nThis package came originally from my `A\nBot `__ project. It was adapted to\nsupport lazy loading of objects, and as a consequence has only four\nclasses (HackerNews, Item, User, Updates), rather than having a class\nfor every type of Item with a complex inheritance model. This version\nalso supports Users and Updates, which the old version did not.\n\nThis package was inspired by the Python Reddit API Wrapper aka PRAW\n(`docs `__/`source `__)\nin its use of objects and iteration methods and ``limit=`` parameters.\n\n.. |Build Status| image:: https://travis-ci.org/jarhill0/hnpy.svg?branch=master\n :target: https://travis-ci.org/jarhill0/hnpy\n.. |Coverage Status| image:: https://coveralls.io/repos/github/jarhill0/hnpy/badge.svg?branch=master\n :target: https://coveralls.io/github/jarhill0/hnpy?branch=master\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jarhill0/hnpy", "keywords": "hacker news api wrapper python3", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hnpy", "package_url": "https://pypi.org/project/hnpy/", "platform": "", "project_url": "https://pypi.org/project/hnpy/", "project_urls": { "Homepage": "https://github.com/jarhill0/hnpy" }, "release_url": "https://pypi.org/project/hnpy/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Yet another object-based Hacker News API wrapper for Python.", "version": "0.2.1" }, "last_serial": 3699929, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a1ad3089917c3eadd676d251def6f8bc", "sha256": "4ec8ca4d94604e45fea6b4bd2afcbf06272e82638c3f8b8c1c8c278cee190d53" }, "downloads": -1, "filename": "hnpy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a1ad3089917c3eadd676d251def6f8bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5012, "upload_time": "2018-01-05T00:04:56", "url": "https://files.pythonhosted.org/packages/3e/23/3285be3e958d08203e3f3bc3b2f9df3ec3f1c5c63ea3a536d9e1dd954acb/hnpy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b648b095efde2f61d506aeda8eb32894", "sha256": "d7f3a7d44b15c0b62ad830e6dca9157fcf048cd3f8ed5446b19e5904997aa161" }, "downloads": -1, "filename": "hnpy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b648b095efde2f61d506aeda8eb32894", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6205, "upload_time": "2018-02-22T05:33:19", "url": "https://files.pythonhosted.org/packages/d9/64/6f880a25fa015b0c68b0db677c527d329a30853850c5b0471a78f7515c6d/hnpy-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2e017fce304dbb5f3ff9b9f7cb69f431", "sha256": "4044e9d60ba6179052faa8cc5fb7c56ca313d015402bebd411875b86baaecd89" }, "downloads": -1, "filename": "hnpy-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2e017fce304dbb5f3ff9b9f7cb69f431", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5867, "upload_time": "2018-02-22T06:47:19", "url": "https://files.pythonhosted.org/packages/a7/2c/cab9c5200eb423d995e3aebb8f4fef8460720d937f1c6d10a8be34aeb2c1/hnpy-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "172c0cd8dd073fa26e76235b648bc4f7", "sha256": "850e544c7f5896435d556fccd1733d53772a473bf1c8cc1c66b197b4bcb8ab72" }, "downloads": -1, "filename": "hnpy-0.1.3.tar.gz", "has_sig": false, "md5_digest": "172c0cd8dd073fa26e76235b648bc4f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6336, "upload_time": "2018-02-22T06:54:14", "url": "https://files.pythonhosted.org/packages/3f/f3/db5ef849b247f296ac9e65be1c3c833623327581d964e859ee1735e1fa8f/hnpy-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "f005a57199f5cb4f9dc017d9d54944c0", "sha256": "3f3cc7fc114f66b515219c457e4e9ff709c411faf9da994eaa4c6b09122395cf" }, "downloads": -1, "filename": "hnpy-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f005a57199f5cb4f9dc017d9d54944c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6244, "upload_time": "2018-02-25T06:17:38", "url": "https://files.pythonhosted.org/packages/15/6a/61fad12a1621125dc1485435b2181b8bd811f8304705c5ad685aa0758edc/hnpy-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "00931ff7170f73adfbfb9cb46d0c70d4", "sha256": "6157f8f155cc10fa2ff1b6f6e90dc75944eda8cc21a8050e106acd05aa3bceb2" }, "downloads": -1, "filename": "hnpy-0.2.1.tar.gz", "has_sig": false, "md5_digest": "00931ff7170f73adfbfb9cb46d0c70d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6262, "upload_time": "2018-03-23T18:26:56", "url": "https://files.pythonhosted.org/packages/b1/0f/a647e91dfa61abbb39cc8e346537e0cbaa5fb20800ecfd097f31d5ee856a/hnpy-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "00931ff7170f73adfbfb9cb46d0c70d4", "sha256": "6157f8f155cc10fa2ff1b6f6e90dc75944eda8cc21a8050e106acd05aa3bceb2" }, "downloads": -1, "filename": "hnpy-0.2.1.tar.gz", "has_sig": false, "md5_digest": "00931ff7170f73adfbfb9cb46d0c70d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6262, "upload_time": "2018-03-23T18:26:56", "url": "https://files.pythonhosted.org/packages/b1/0f/a647e91dfa61abbb39cc8e346537e0cbaa5fb20800ecfd097f31d5ee856a/hnpy-0.2.1.tar.gz" } ] }