<div align="center">
<img src="https://raw.githubusercontent.com/joeyagreco/hacker-news/main/img/hacker_news.png" alt="hacker news logo" width="300"/>
<h1>Hacker News SDK</h1>
<h3>A Python Wrapper for the Hacker News API</h3>
[Hacker News API Documentation](https://github.com/HackerNews/API/blob/master/README.md)
<a target="_blank" href="https://www.python.org/downloads/" title="Python version"><img src="https://img.shields.io/badge/python-%3E=_3.10-teal.svg"></a>
![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/hacker-news)
<br>
![E2E Tests](https://github.com/joeyagreco/hacker-news/actions/workflows/e2e-tests.yml/badge.svg)
![Build](https://github.com/joeyagreco/hacker-news/actions/workflows/build.yml/badge.svg)
![Formatting Check](https://github.com/joeyagreco/hacker-news/actions/workflows/formatting-check.yml/badge.svg)
</div>
## Quickstart
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install.
```bash
pip install hn-sdk
```
### Get an Item by ID
#### Story
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(8863))
```
```sh
{
"by" : "dhouston",
"descendants" : 71,
"id" : 8863,
"kids" : [ 8952, 9224, 8917, 8884, ..., 8876 ],
"score" : 111,
"time" : 1175714200,
"title" : "My YC app: Dropbox - Throw away your USB drive",
"type" : "story",
"url" : "http://www.getdropbox.com/u/2/screencast.html"
}
```
#### Comment
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(2921983))
```
```sh
{
"by" : "norvig",
"id" : 2921983,
"kids" : [ 2922097, 2922429, 2924562, 2922709, ..., 2922141 ],
"parent" : 2921506,
"text" : "Aw shucks, guys ... you make me blush with your compliments.<p>Tell you what, Ill make a deal: I'll keep writing if you keep reading. K?",
"time" : 1314211127,
"type" : "comment"
}
```
#### Ask
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(121003))
```
```sh
{
"by" : "tel",
"descendants" : 16,
"id" : 121003,
"kids" : [ 121016, 121109, 121168 ],
"score" : 25,
"text" : "<i>or</i> HN: the Next Iteration<p>I get the impression that with Arc being released a lot of people who never had time for HN before are suddenly dropping in more often. (PG: what are the numbers on this? I'm envisioning a spike.)<p>Not to say that isn't great, but I'm wary of Diggification. Between links comparing programming to sex and a flurry of gratuitous, ostentatious adjectives in the headlines it's a bit concerning.<p>80% of the stuff that makes the front page is still pretty awesome, but what's in place to keep the signal/noise ratio high? Does the HN model still work as the community scales? What's in store for (++ HN)?",
"time" : 1203647620,
"title" : "Ask HN: The Arc Effect",
"type" : "story"
}
```
#### Job
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(121003))
```
```sh
{
"by" : "justin",
"id" : 192327,
"score" : 6,
"text" : "Justin.tv is the biggest live video site online. We serve hundreds of thousands of video streams a day, and have supported up to 50k live concurrent viewers. Our site is growing every week, and we just added a 10 gbps line to our colo. Our unique visitors are up 900% since January.<p>There are a lot of pieces that fit together to make Justin.tv work: our video cluster, IRC server, our web app, and our monitoring and search services, to name a few. A lot of our website is dependent on Flash, and we're looking for talented Flash Engineers who know AS2 and AS3 very well who want to be leaders in the development of our Flash.<p>Responsibilities<p><pre><code> * Contribute to product design and implementation discussions\n * Implement projects from the idea phase to production\n * Test and iterate code before and after production release \n</code></pre>\nQualifications<p><pre><code> * You should know AS2, AS3, and maybe a little be of Flex.\n * Experience building web applications.\n * A strong desire to work on website with passionate users and ideas for how to improve it.\n * Experience hacking video streams, python, Twisted or rails all a plus.\n</code></pre>\nWhile we're growing rapidly, Justin.tv is still a small, technology focused company, built by hackers for hackers. Seven of our ten person team are engineers or designers. We believe in rapid development, and push out new code releases every week. We're based in a beautiful office in the SOMA district of SF, one block from the caltrain station. If you want a fun job hacking on code that will touch a lot of people, JTV is for you.<p>Note: You must be physically present in SF to work for JTV. Completing the technical problem at <a href=\"http://www.justin.tv/problems/bml\" rel=\"nofollow\">http://www.justin.tv/problems/bml</a> will go a long way with us. Cheers!",
"time" : 1210981217,
"title" : "Justin.tv is looking for a Lead Flash Engineer!",
"type" : "job",
"url" : ""
}
```
#### Poll
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(126809))
```
```sh
{
"by" : "pg",
"descendants" : 54,
"id" : 126809,
"kids" : [ 126822, 126823, 126993, 126824, ..., 126875 ],
"parts" : [ 126810, 126811, 126812 ],
"score" : 46,
"text" : "",
"time" : 1204403652,
"title" : "Poll: What would happen if News.YC had explicit support for polls?",
"type" : "poll"
}
```
#### Part of Another Item
```python
from hn_sdk.client.v0.client import get_item_by_id
print(get_item_by_id(160705))
```
```sh
{
"by" : "pg",
"id" : 160705,
"poll" : 160704,
"score" : 335,
"text" : "Yes, ban them; I'm tired of seeing Valleywag stories on News.YC.",
"time" : 1207886576,
"type" : "pollopt"
}
```
---
### Get a User by Username
```python
from hn_sdk.client.v0.client import get_user_by_username
print(get_user_by_username("joeyagreco"))
```
```sh
{
"created": 1663896930,
"id": "joeyagreco",
"karma": 4,
"submitted": [38474886, 35729377, 35729231, 32946977, 32946976],
}
```
---
### Get Current Largest Item ID
```python
from hn_sdk.client.v0.client import get_max_item_id
print(get_max_item_id())
```
```sh
39438426
```
---
### Get New Stories
```python
from hn_sdk.client.v0.client import get_new_stories
print(get_new_stories())
```
```sh
[ 39431573, 39431552, 39431514, 39431505, ..., 39432231 ]
```
---
### Get Top Stories
```python
from hn_sdk.client.v0.client import get_top_stories
print(get_top_stories())
```
```sh
[ 39396571, 39385098, 39387191, 39389092, ..., 39394528 ]
```
---
### Get Best Stories
```python
from hn_sdk.client.v0.client import get_best_stories
print(get_best_stories())
```
```sh
[ 39437424, 39418810, 39418102, 39422238, ..., 39402906 ]
```
---
### Get Ask HN Stories
```python
from hn_sdk.client.v0.client import get_ask_stories
print(get_ask_stories())
```
```sh
[ 39405805, 39405655, 39400290, 39398791, ..., 39427773 ]
```
---
### Get Show HN Stories
```python
from hn_sdk.client.v0.client import get_show_stories
print(get_show_stories())
```
```sh
[ 39387382, 39403234, 39410058, 39391731, ..., 39390544 ]
```
---
### Get Job Stories
```python
from hn_sdk.client.v0.client import get_job_stories
print(get_job_stories())
```
```sh
[ 39057748, 39040718, 39038845, 39019063, ..., 39006337 ]
```
---
### Get Changed Items and Profiles
```python
from hn_sdk.client.v0.client import get_updates
print(get_updates())
```
```sh
{
"items" : [ 8423305, 8420805, 8423379, 8422504, ..., 8422087 ],
"profiles" : [ "thefox", "mdda", "plinkplonk", "GBond", ..., "Bogdanp" ]
}
```
## Development
### Install Dependencies
```sh
make deps
```
### Run E2E Tests
```sh
make test-e2e
```
### Format Code
```sh
make fmt
```
Raw data
{
"_id": null,
"home_page": "https://github.com/joeyagreco/hn-api",
"name": "hn-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "hacker-news hacker news api sdk",
"author": "Joey Greco",
"author_email": "joeyagreco@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/25/7b/b694e6335c89262790b4cd91a117ce7466a60bcc740d867531a633390244/hn-sdk-0.1.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img src=\"https://raw.githubusercontent.com/joeyagreco/hacker-news/main/img/hacker_news.png\" alt=\"hacker news logo\" width=\"300\"/>\n<h1>Hacker News SDK</h1>\n<h3>A Python Wrapper for the Hacker News API</h3>\n\n[Hacker News API Documentation](https://github.com/HackerNews/API/blob/master/README.md)\n\n\n<a target=\"_blank\" href=\"https://www.python.org/downloads/\" title=\"Python version\"><img src=\"https://img.shields.io/badge/python-%3E=_3.10-teal.svg\"></a>\n![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/hacker-news)\n<br>\n![E2E Tests](https://github.com/joeyagreco/hacker-news/actions/workflows/e2e-tests.yml/badge.svg)\n![Build](https://github.com/joeyagreco/hacker-news/actions/workflows/build.yml/badge.svg)\n![Formatting Check](https://github.com/joeyagreco/hacker-news/actions/workflows/formatting-check.yml/badge.svg)\n</div>\n\n## Quickstart\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install.\n\n```bash\npip install hn-sdk\n```\n\n### Get an Item by ID\n\n#### Story\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(8863))\n```\n```sh\n{\n \"by\" : \"dhouston\",\n \"descendants\" : 71,\n \"id\" : 8863,\n \"kids\" : [ 8952, 9224, 8917, 8884, ..., 8876 ],\n \"score\" : 111,\n \"time\" : 1175714200,\n \"title\" : \"My YC app: Dropbox - Throw away your USB drive\",\n \"type\" : \"story\",\n \"url\" : \"http://www.getdropbox.com/u/2/screencast.html\"\n}\n```\n\n#### Comment\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(2921983))\n```\n```sh\n{\n \"by\" : \"norvig\",\n \"id\" : 2921983,\n \"kids\" : [ 2922097, 2922429, 2924562, 2922709, ..., 2922141 ],\n \"parent\" : 2921506,\n \"text\" : \"Aw shucks, guys ... you make me blush with your compliments.<p>Tell you what, Ill make a deal: I'll keep writing if you keep reading. K?\",\n \"time\" : 1314211127,\n \"type\" : \"comment\"\n}\n```\n\n#### Ask\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(121003))\n```\n```sh\n{\n \"by\" : \"tel\",\n \"descendants\" : 16,\n \"id\" : 121003,\n \"kids\" : [ 121016, 121109, 121168 ],\n \"score\" : 25,\n \"text\" : \"<i>or</i> HN: the Next Iteration<p>I get the impression that with Arc being released a lot of people who never had time for HN before are suddenly dropping in more often. (PG: what are the numbers on this? I'm envisioning a spike.)<p>Not to say that isn't great, but I'm wary of Diggification. Between links comparing programming to sex and a flurry of gratuitous, ostentatious adjectives in the headlines it's a bit concerning.<p>80% of the stuff that makes the front page is still pretty awesome, but what's in place to keep the signal/noise ratio high? Does the HN model still work as the community scales? What's in store for (++ HN)?\",\n \"time\" : 1203647620,\n \"title\" : \"Ask HN: The Arc Effect\",\n \"type\" : \"story\"\n}\n```\n\n#### Job\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(121003))\n```\n```sh\n{\n \"by\" : \"justin\",\n \"id\" : 192327,\n \"score\" : 6,\n \"text\" : \"Justin.tv is the biggest live video site online. We serve hundreds of thousands of video streams a day, and have supported up to 50k live concurrent viewers. Our site is growing every week, and we just added a 10 gbps line to our colo. Our unique visitors are up 900% since January.<p>There are a lot of pieces that fit together to make Justin.tv work: our video cluster, IRC server, our web app, and our monitoring and search services, to name a few. A lot of our website is dependent on Flash, and we're looking for talented Flash Engineers who know AS2 and AS3 very well who want to be leaders in the development of our Flash.<p>Responsibilities<p><pre><code> * Contribute to product design and implementation discussions\\n * Implement projects from the idea phase to production\\n * Test and iterate code before and after production release \\n</code></pre>\\nQualifications<p><pre><code> * You should know AS2, AS3, and maybe a little be of Flex.\\n * Experience building web applications.\\n * A strong desire to work on website with passionate users and ideas for how to improve it.\\n * Experience hacking video streams, python, Twisted or rails all a plus.\\n</code></pre>\\nWhile we're growing rapidly, Justin.tv is still a small, technology focused company, built by hackers for hackers. Seven of our ten person team are engineers or designers. We believe in rapid development, and push out new code releases every week. We're based in a beautiful office in the SOMA district of SF, one block from the caltrain station. If you want a fun job hacking on code that will touch a lot of people, JTV is for you.<p>Note: You must be physically present in SF to work for JTV. Completing the technical problem at <a href=\\\"http://www.justin.tv/problems/bml\\\" rel=\\\"nofollow\\\">http://www.justin.tv/problems/bml</a> will go a long way with us. Cheers!\",\n \"time\" : 1210981217,\n \"title\" : \"Justin.tv is looking for a Lead Flash Engineer!\",\n \"type\" : \"job\",\n \"url\" : \"\"\n}\n```\n\n#### Poll\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(126809))\n```\n```sh\n{\n \"by\" : \"pg\",\n \"descendants\" : 54,\n \"id\" : 126809,\n \"kids\" : [ 126822, 126823, 126993, 126824, ..., 126875 ],\n \"parts\" : [ 126810, 126811, 126812 ],\n \"score\" : 46,\n \"text\" : \"\",\n \"time\" : 1204403652,\n \"title\" : \"Poll: What would happen if News.YC had explicit support for polls?\",\n \"type\" : \"poll\"\n}\n```\n\n#### Part of Another Item\n```python\nfrom hn_sdk.client.v0.client import get_item_by_id\n\nprint(get_item_by_id(160705))\n```\n```sh\n{\n \"by\" : \"pg\",\n \"id\" : 160705,\n \"poll\" : 160704,\n \"score\" : 335,\n \"text\" : \"Yes, ban them; I'm tired of seeing Valleywag stories on News.YC.\",\n \"time\" : 1207886576,\n \"type\" : \"pollopt\"\n}\n```\n---\n### Get a User by Username\n\n```python\nfrom hn_sdk.client.v0.client import get_user_by_username\n\nprint(get_user_by_username(\"joeyagreco\"))\n```\n```sh\n{\n \"created\": 1663896930,\n \"id\": \"joeyagreco\",\n \"karma\": 4,\n \"submitted\": [38474886, 35729377, 35729231, 32946977, 32946976],\n}\n```\n---\n### Get Current Largest Item ID\n```python\nfrom hn_sdk.client.v0.client import get_max_item_id\n\nprint(get_max_item_id())\n```\n```sh\n39438426\n```\n---\n### Get New Stories\n```python\nfrom hn_sdk.client.v0.client import get_new_stories\n\nprint(get_new_stories())\n```\n```sh\n[ 39431573, 39431552, 39431514, 39431505, ..., 39432231 ]\n```\n---\n### Get Top Stories\n```python\nfrom hn_sdk.client.v0.client import get_top_stories\n\nprint(get_top_stories())\n```\n```sh\n[ 39396571, 39385098, 39387191, 39389092, ..., 39394528 ]\n```\n---\n### Get Best Stories\n```python\nfrom hn_sdk.client.v0.client import get_best_stories\n\nprint(get_best_stories())\n```\n```sh\n[ 39437424, 39418810, 39418102, 39422238, ..., 39402906 ]\n```\n---\n### Get Ask HN Stories\n```python\nfrom hn_sdk.client.v0.client import get_ask_stories\n\nprint(get_ask_stories())\n```\n```sh\n[ 39405805, 39405655, 39400290, 39398791, ..., 39427773 ]\n```\n---\n### Get Show HN Stories\n```python\nfrom hn_sdk.client.v0.client import get_show_stories\n\nprint(get_show_stories())\n```\n```sh\n[ 39387382, 39403234, 39410058, 39391731, ..., 39390544 ]\n```\n---\n### Get Job Stories\n```python\nfrom hn_sdk.client.v0.client import get_job_stories\n\nprint(get_job_stories())\n```\n```sh\n[ 39057748, 39040718, 39038845, 39019063, ..., 39006337 ]\n```\n---\n### Get Changed Items and Profiles\n```python\nfrom hn_sdk.client.v0.client import get_updates\n\nprint(get_updates())\n```\n```sh\n{\n \"items\" : [ 8423305, 8420805, 8423379, 8422504, ..., 8422087 ],\n \"profiles\" : [ \"thefox\", \"mdda\", \"plinkplonk\", \"GBond\", ..., \"Bogdanp\" ]\n}\n```\n\n## Development\n\n### Install Dependencies\n```sh\nmake deps\n```\n\n### Run E2E Tests\n```sh\nmake test-e2e\n```\n\n### Format Code\n```sh\nmake fmt\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python wrapper for the Hacker News API.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/joeyagreco/hn-api"
},
"split_keywords": [
"hacker-news",
"hacker",
"news",
"api",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "69ac8dbdec98c1b3386869d1c8269891e19743b4d49a23e75fe2838c7141afe1",
"md5": "af48fac2bf814fd0088c24c1d6870c33",
"sha256": "2a834fb8a901c1c3a416dcc0ffe6d1e295bf43a61237381099767a9024a09bca"
},
"downloads": -1,
"filename": "hn_sdk-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af48fac2bf814fd0088c24c1d6870c33",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8720,
"upload_time": "2024-05-27T21:40:04",
"upload_time_iso_8601": "2024-05-27T21:40:04.456009Z",
"url": "https://files.pythonhosted.org/packages/69/ac/8dbdec98c1b3386869d1c8269891e19743b4d49a23e75fe2838c7141afe1/hn_sdk-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "257bb694e6335c89262790b4cd91a117ce7466a60bcc740d867531a633390244",
"md5": "3cb2dcc84a43926b1db2937a10817c0e",
"sha256": "42a2ece1fa0c5e476080d5970e168aa8f2da6ea59f184892b307171cc75782ea"
},
"downloads": -1,
"filename": "hn-sdk-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3cb2dcc84a43926b1db2937a10817c0e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11162,
"upload_time": "2024-05-27T21:40:06",
"upload_time_iso_8601": "2024-05-27T21:40:06.227490Z",
"url": "https://files.pythonhosted.org/packages/25/7b/b694e6335c89262790b4cd91a117ce7466a60bcc740d867531a633390244/hn-sdk-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-27 21:40:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "joeyagreco",
"github_project": "hn-api",
"github_not_found": true,
"lcname": "hn-sdk"
}