Hacker News Client 
The Hacker News Client is a Python-based tool designed to seamlessly engage with the official Hacker News Firebase API. This client incorporates a built-in request-cache mechanism for each API call, allowing for the efficient handling of complete data dumps without the need for redundant subsequent calls. This feature significantly optimizes your data wrangling processes, saving you time and resources.
Install 
pip install hnclient
Quick Start 
First step is to initialize HackerNewsClient prior to making an API request. By default, client requests are cached. To disable cache, set the disable_cache argument to True:
from hnclient import HackerNewsClient
client = HackerNewsClient()
To fetch stories from Hacker News, begin by using the getstories method.
-
💡 You can select specific story section by passing its name into the story argument. Here are few examples:
Top,Best,Ask,Show. -
💡 You can also set the sorting order for all stories by their Hacker News score with the
descendingargument. Default isFalse.
from hnclient import HackerNewsClient
client = HackerNewsClient()
data = client.get_stories("top", descending=False)
print(data)
The program above will print out a list of dictionaries where each dictionary holds the following metadata per story: 👇
{'author': 'tristanho',
'comments': 156,
'id': 34006202,
'score': 318,
'text': 'Hey HN, cofounder of Readwise here. We've been working on this '
'cross-platform reader app for about 2 years, excited to finally...' ,
'time': 1671140643,
'title': 'Show HN: Readwise Reader, an all-in-one reading app',
'url': 'https://readwise.io/read'}
Data Wrangling 
- Collect a list of a specific metadata object. The available list of objects can be found in the printed dictionary above. For the example below, we are obtaining a list of all URLS pertaining to the Top stories:
from hnclient import HackerNewsClient
client = HackerNewsClient()
data = client.get_stories("top")
urls = client.get_item("url", data)
print(urls)
outputs:
['https://github.com/ifeelalright1970/ytmp',
'https://mimosa.so/',
'https://www.screen.studio/',
'https://www.pinetarpoker.com',
...]
- Select a random story from the client payload. For the example below, we are obtaiing a story pertaining from the Best stories.
from hnclient import HackerNewsClient
client = HackerNewsClient()
data = client.get_stories("best")
random = client.get_random_story(data)
print(random)
Metadata
Release files for hnclient 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hnclient-0.0.2.tar.gz | 8.8 kB | Without provenance | Details for hnclient-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hnclient-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for hnclient-0.0.2-py3-none-any.whl |
Total release size: 18.5 kB
Release files / hnclient-0.0.2.tar.gz
| Download URL | hnclient-0.0.2.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d03bc212f85923f1bd533ed783033edf4429183052ae7d87664411225aa86f6
|
|
BLAKE2b-256 checksum How to use checksums |
bffc984b9783a7ea1371f969c600d667e2ec2d518ce6acca8b09c61eb69dbc8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / hnclient-0.0.2-py3-none-any.whl
| Download URL | hnclient-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
feace38a5f376342d15d5f8845c2084cff5c9727d09c92bf490865c4cfb5c4e5
|
|
BLAKE2b-256 checksum How to use checksums |
611be7bad32ff4e9745614da58623af8f7530b2363d71a856f143173e537dd0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for hnclient 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.