Skip to main content

A Python wrapper for the Hacker News API.

Project description

hacker news logo

Hacker News SDK

A Python Wrapper for the Hacker News API

Hacker News API Documentation

Last Commit
E2E Tests Build Formatting Check

Quickstart

Use the package manager pip to install.

pip install hn-sdk

Get an Item by ID

Story

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(8863))
{
  "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

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(2921983))
{
  "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

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(121003))
{
  "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

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(121003))
{
  "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

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(126809))
{
  "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

from hn_sdk.client.v0.client import get_item_by_id

print(get_item_by_id(160705))
{
  "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

from hn_sdk.client.v0.client import get_user_by_username

print(get_user_by_username("joeyagreco"))
{
    "created": 1663896930,
    "id": "joeyagreco",
    "karma": 4,
    "submitted": [38474886, 35729377, 35729231, 32946977, 32946976],
}

Get Current Largest Item ID

from hn_sdk.client.v0.client import get_max_item_id

print(get_max_item_id())
39438426

Get New Stories

from hn_sdk.client.v0.client import get_new_stories

print(get_new_stories())
[ 39431573, 39431552, 39431514, 39431505, ..., 39432231 ]

Get Top Stories

from hn_sdk.client.v0.client import get_top_stories

print(get_top_stories())
[ 39396571, 39385098, 39387191, 39389092, ..., 39394528 ]

Get Best Stories

from hn_sdk.client.v0.client import get_best_stories

print(get_best_stories())
[ 39437424, 39418810, 39418102, 39422238, ..., 39402906 ]

Get Ask HN Stories

from hn_sdk.client.v0.client import get_ask_stories

print(get_ask_stories())
[ 39405805, 39405655, 39400290, 39398791,  ..., 39427773 ]

Get Show HN Stories

from hn_sdk.client.v0.client import get_show_stories

print(get_show_stories())
[ 39387382, 39403234, 39410058, 39391731,  ..., 39390544 ]

Get Job Stories

from hn_sdk.client.v0.client import get_job_stories

print(get_job_stories())
[ 39057748, 39040718, 39038845, 39019063,  ..., 39006337 ]

Get Changed Items and Profiles

from hn_sdk.client.v0.client import get_updates

print(get_updates())
{
  "items" : [ 8423305, 8420805, 8423379, 8422504, ..., 8422087 ],
  "profiles" : [ "thefox", "mdda", "plinkplonk", "GBond", ..., "Bogdanp" ]
}

Development

Install Dependencies

make deps

Run E2E Tests

make test-e2e

Format Code

make fmt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hn-sdk-0.1.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

hn_sdk-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file hn-sdk-0.1.1.tar.gz.

File metadata

  • Download URL: hn-sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for hn-sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 42a2ece1fa0c5e476080d5970e168aa8f2da6ea59f184892b307171cc75782ea
MD5 3cb2dcc84a43926b1db2937a10817c0e
BLAKE2b-256 257bb694e6335c89262790b4cd91a117ce7466a60bcc740d867531a633390244

See more details on using hashes here.

File details

Details for the file hn_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hn_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for hn_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a834fb8a901c1c3a416dcc0ffe6d1e295bf43a61237381099767a9024a09bca
MD5 af48fac2bf814fd0088c24c1d6870c33
BLAKE2b-256 69ac8dbdec98c1b3386869d1c8269891e19743b4d49a23e75fe2838c7141afe1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page