The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Title: Wrapper for the 'Official Hacker News' API
Version: 0.2.1
Maintainer: Ryszard Szymanski <ryszard.szymanski@outlook.com>
Description: Use the Official Hacker News API through R. Retrieve posts, articles and other items in form of convenient R objects.
License: MIT + file LICENSE
Encoding: UTF-8
Suggests: covr, testthat (≥ 2.1.0), httptest2, knitr, rmarkdown, spelling, tibble
RoxygenNote: 7.3.2
Imports: utils, httr2
VignetteBuilder: knitr
URL: https://github.com/szymanskir/hackeRnews
BugReports: https://github.com/szymanskir/hackeRnews/issues
Language: en-US
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-04-08 06:52:56 UTC; Rysza
Author: Ryszard Szymanski [aut, cre], Piotr Janus [aut], Zuzanna Magierska [aut], Rafal Muszynski [aut], Andrzej Nowikowski [aut]
Repository: CRAN
Date/Publication: 2025-04-08 07:10:02 UTC

Hacker News best stories

Description

Retrieves best stories using Hacker News API

Usage

get_best_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available

Value

list of best stories

Examples



# get the best story on Hacker News
best_story <- get_best_stories(max_items = 1)
best_story

# get top 20 best stories on Hacker News
best_20_stories <- get_best_stories(max_items = 20)
best_20_stories

# get all best stories on Hacker News
best_stories <- get_best_stories()
best_stories


Hacker News best stories ids

Description

Retrieves best stories ids using Hacker News API

Usage

get_best_stories_ids()

Value

list of best stories ids

Examples


# get the ids of best stories on Hacker News
best_stories_ids <- get_best_stories_ids()
best_stories_ids



Hacker News nested comments

Description

Retrieves all comments under an item using Hacker News API

Usage

get_comments(item)

Arguments

item

item whose children (comments) will be retrieved

Value

dataframe of all comments under an item

Examples


story <- get_item_by_id(21499889)
comments <- get_comments(story)

# Convert to a tibble to improve formatting
# as comment content might long
tibble::as_tibble(comments)



Get Hacker News by Id

Description

Retrieves the item corresponding to specified id using Hacker News API

Usage

get_item_by_id(id)

Arguments

id

id of the item that should be retrieved

Details

The API in some cases returns a null response. When this situation occurs it is assumed that the item does not exist and NA is returned.

Value

item corresponding to the specified id

Examples


# retrieve the id of the latest Hacker News item
last_item_id <- get_max_item_id()
last_item_id

# retrieve the latest Hacker News item
last_hn_item <- get_item_by_id(last_item_id)
last_hn_item



Get Hacker News by ids

Description

Retrieves items corresponding to specified list of ids using Hacker News API

Usage

get_items_by_ids(ids)

Arguments

ids

list of ids

Value

list of hn_item objects

Examples


# retrieve the first two items on Hacker News
items <- get_items_by_ids(c(1,2))
items



Hacker News latest ask stories

Description

Retrieves latest ask stories using Hacker News API

Usage

get_latest_ask_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available

Value

list of latest ask HN stories ids

Examples



# get the lastest ask story on Hacker News
latest_ask_story <- get_latest_ask_stories(max_items = 1)
latest_ask_story

# get 10 latest ask stories on Hacker News
latest_10_ask_stories <- get_latest_ask_stories(max_items = 10)
latest_10_ask_stories

# get all latest ask stories on Hacker News
latest_ask_stories <- get_latest_ask_stories()
latest_ask_stories


Hacker News latest ask stories ids

Description

Retrieves latest ask stories ids using Hacker News API

Usage

get_latest_ask_stories_ids()

Value

list of latest ask Hacker News stories ids

Examples


# get ids of latest ask stories
ask_stories_ids <- get_latest_ask_stories_ids()
ask_stories_ids



Hacker News latest job stories

Description

Retrieves latest job stories using Hacker News API

Usage

get_latest_job_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available

Value

list of latest job stories

Examples



# get the latest job story on Hacker News
latest_job_story <- get_latest_job_stories(max_items = 1)
latest_job_story

# get 10 latest job stories on Hacker News
latest_10_job_stories <- get_latest_job_stories(max_items = 10)
latest_10_job_stories

# get all latest job stories on Hacker News
latest_job_stories <- get_latest_job_stories()
latest_job_stories



Hacker News latest job stories ids

Description

Retrieves latest job stories ids using Hacker News API

Usage

get_latest_job_stories_ids()

Value

list of latest job stories ids

Examples


# get ids of latest job stories
latest_job_stories_ids <- get_latest_job_stories_ids()
latest_job_stories_ids



Hacker News latest show stories

Description

Retrieves latest show stories using Hacker News API

Usage

get_latest_show_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available

Value

list of latest show HN stories

Examples



# get the latest show story on Hacker News
latest_show_story <- get_latest_show_stories(max_items = 1)
latest_show_story

# get 10 latest show stories on Hacker News
latest_10_show_stories <- get_latest_show_stories(max_items = 10)
latest_10_show_stories

# get all latest show stories on Hacker News
latest_show_stories <- get_latest_show_stories()
latest_show_stories


Hacker News latest show stories ids

Description

Retrieves latest show stories ids using Hacker News API

Usage

get_latest_show_stories_ids()

Value

list of latest show Hacker News stories ids

Examples


# get ids of latest show stories on Hacker News
show_stories_ids <- get_latest_show_stories_ids()
show_stories_ids



Hacker News item largest id

Description

Retrieves largest item id available via Hacker News API

Usage

get_max_item_id()

Value

current largest item id

Examples


# retrieve the id of the latest item
get_max_item_id()



Hacker News newest stories

Description

Retrieves newest stories using Hacker News API

Usage

get_new_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available

Value

list of new stories

Examples



# get the newest story on Hacker News
newest_story <- get_new_stories(max_items = 1)
newest_story

# get all new stories on Hacker News
new_stories <- get_new_stories()
new_stories



Hacker News newest stories ids

Description

Retrieves newest stories ids using Hacker News API

Usage

get_new_stories_ids()

Value

list of new stories ids

Examples


# get ids of new stories on Hacker News
new_stories_ids <- get_new_stories_ids()
new_stories_ids



Hacker News top stories

Description

Retrieves top stories using Hacker News API

Usage

get_top_stories(max_items = NULL)

Arguments

max_items

Maximum number of items to retrieve. If max_items = NULL, returns all available stories

Value

List of top stories

Examples



# get the top story on Hacker News
top_story <- get_top_stories(max_items = 1)
top_story

# get all top stories on Hacker News
top_stories <- get_top_stories()
top_stories



Hacker News top stories ids

Description

Retrieves top stories ids using Hacker News API

Usage

get_top_stories_ids()

Value

list of top stories ids

Examples



# retrieve the ids of current top stories on Hacker News
top_stories_ids <- get_top_stories_ids()
top_stories_ids



Hacker News updated profiles

Description

Retrieves changed item ids and changed profile usernames using Hacker News API

Usage

get_updates()

Value

list of changed item ids and list of changed profile usernames

Examples


# get ids/usernames of updated items/profiles
hn_updates <- get_updates()
hn_updates



Get Hacker News user

Description

Get user corresponding to the specified username

Usage

get_user_by_username(username)

Arguments

username

of the user that should be retrieved

Value

user corresponding to the specified username

Examples


# Retrieve information about the jl user
get_user_by_username("jl")



Print for "hn_item" type objects

Description

Print for "hn_item" type objects

Usage

## S3 method for class 'hn_item'
print(x, ...)

Arguments

x

"hn_item" type list

...

further arguments passed to or from other methods


Print for "hn_user" type objects

Description

Print for "hn_user" type objects

Usage

## S3 method for class 'hn_user'
print(x, ...)

Arguments

x

"hn_user" type list

...

further arguments passed to or from other methods

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.