Title: | Wrapper for the 'Official Hacker News' API |
---|---|
Description: | Use the <https://hacker-news.firebaseio.com/v0/> API through R. Retrieve posts, articles and other items in form of convenient R objects. |
Authors: | Ryszard Szymanski [aut, cre], Piotr Janus [aut], Zuzanna Magierska [aut], Rafal Muszynski [aut], Andrzej Nowikowski [aut] |
Maintainer: | Ryszard Szymanski <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2025-03-05 03:17:01 UTC |
Source: | https://github.com/szymanskir/hackernews |
Retrieves best stories using Hacker News API
get_best_stories(max_items = NULL)
get_best_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of best stories
# 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
# 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
Retrieves best stories ids using Hacker News API
get_best_stories_ids()
get_best_stories_ids()
list of best stories ids
# get the ids of best stories on Hacker News best_stories_ids <- get_best_stories_ids() best_stories_ids
# get the ids of best stories on Hacker News best_stories_ids <- get_best_stories_ids() best_stories_ids
Retrieves all comments under an item using Hacker News API
get_comments(item)
get_comments(item)
item |
item whose children (comments) will be retrieved |
dataframe of all comments under an item
story <- get_item_by_id(21499889) comments <- get_comments(story) comments
story <- get_item_by_id(21499889) comments <- get_comments(story) comments
Retrieves the item corresponding to specified id using Hacker News API
get_item_by_id(id)
get_item_by_id(id)
id |
id of the item that should be retrieved |
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.
item corresponding to the specified id
# 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
# 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
Retrieves items corresponding to specified list of ids using Hacker News API
get_items_by_ids(ids)
get_items_by_ids(ids)
ids |
list of ids |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of hn_item objects
https://github.com/HenrikBengtsson/future https://github.com/HenrikBengtsson/future.apply
# retrieve the first two items on Hacker News items <- get_items_by_ids(c(1,2)) items
# retrieve the first two items on Hacker News items <- get_items_by_ids(c(1,2)) items
Retrieves latest ask stories using Hacker News API
get_latest_ask_stories(max_items = NULL)
get_latest_ask_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of latest ask HN stories ids
# 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
# 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
Retrieves latest ask stories ids using Hacker News API
get_latest_ask_stories_ids()
get_latest_ask_stories_ids()
list of latest ask Hacker News stories ids
# get ids of latest ask stories ask_stories_ids <- get_latest_ask_stories_ids() ask_stories_ids
# get ids of latest ask stories ask_stories_ids <- get_latest_ask_stories_ids() ask_stories_ids
Retrieves latest job stories using Hacker News API
get_latest_job_stories(max_items = NULL)
get_latest_job_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of latest job stories
# 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
# 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
Retrieves latest job stories ids using Hacker News API
get_latest_job_stories_ids()
get_latest_job_stories_ids()
list of latest job stories ids
# get ids of latest job stories latest_job_stories_ids <- get_latest_job_stories_ids() latest_job_stories_ids
# get ids of latest job stories latest_job_stories_ids <- get_latest_job_stories_ids() latest_job_stories_ids
Retrieves latest show stories using Hacker News API
get_latest_show_stories(max_items = NULL)
get_latest_show_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of latest show HN stories
# 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
# 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
Retrieves latest show stories ids using Hacker News API
get_latest_show_stories_ids()
get_latest_show_stories_ids()
list of latest show Hacker News stories ids
# get ids of latest show stories on Hacker News show_stories_ids <- get_latest_show_stories_ids() show_stories_ids
# get ids of latest show stories on Hacker News show_stories_ids <- get_latest_show_stories_ids() show_stories_ids
Retrieves largest item id available via Hacker News API
get_max_item_id()
get_max_item_id()
current largest item id
# retrieve the id of the latest item get_max_item_id()
# retrieve the id of the latest item get_max_item_id()
Retrieves newest stories using Hacker News API
get_new_stories(max_items = NULL)
get_new_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
list of new stories
# 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
# 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
Retrieves newest stories ids using Hacker News API
get_new_stories_ids()
get_new_stories_ids()
list of new stories ids
# get ids of new stories on Hacker News new_stories_ids <- get_new_stories_ids() new_stories_ids
# get ids of new stories on Hacker News new_stories_ids <- get_new_stories_ids() new_stories_ids
Retrieves top stories using Hacker News API
get_top_stories(max_items = NULL)
get_top_stories(max_items = NULL)
max_items |
Maximum number of items to retrieve. If max_items = NULL, returns all available stories |
Parallel api requests can be enabled by running
future::plan(future::multiprocess)
List of top stories
# 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
# 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
Retrieves top stories ids using Hacker News API
get_top_stories_ids()
get_top_stories_ids()
list of top stories ids
# retrieve the ids of current top stories on Hacker News top_stories_ids <- get_top_stories_ids() top_stories_ids
# retrieve the ids of current top stories on Hacker News top_stories_ids <- get_top_stories_ids() top_stories_ids
Retrieves changed item ids and changed profile usernames using Hacker News API
get_updates()
get_updates()
list of changed item ids and list of changed profile usernames
# get ids/usernames of updated items/profiles hn_updates <- get_updates() hn_updates
# get ids/usernames of updated items/profiles hn_updates <- get_updates() hn_updates
Get user corresponding to the specified username
get_user_by_username(username)
get_user_by_username(username)
username |
of the user that should be retrieved |
user corresponding to the specified username
# Retrieve information about the jl user get_user_by_username("jl")
# Retrieve information about the jl user get_user_by_username("jl")
Print for "hn_item" type objects
## S3 method for class 'hn_item' print(x, ...)
## S3 method for class 'hn_item' print(x, ...)
x |
"hn_item" type list |
... |
further arguments passed to or from other methods |
Print for "hn_user" type objects
## S3 method for class 'hn_user' print(x, ...)
## S3 method for class 'hn_user' print(x, ...)
x |
"hn_user" type list |
... |
further arguments passed to or from other methods |