{"id":26517254,"url":"https://github.com/fraction/node-hacker-news-api","last_synced_at":"2025-03-21T08:19:17.377Z","repository":{"id":15969098,"uuid":"18711869","full_name":"fraction/node-hacker-news-api","owner":"fraction","description":"A Node.js client library for seamless integration with Algolia's kickass Hacker News API.","archived":false,"fork":false,"pushed_at":"2023-03-03T11:21:18.000Z","size":353,"stargazers_count":24,"open_issues_count":3,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-14T12:12:29.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fraction.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-12T18:51:14.000Z","updated_at":"2024-06-21T04:19:31.612Z","dependencies_parsed_at":"2024-06-21T04:29:29.373Z","dependency_job_id":null,"html_url":"https://github.com/fraction/node-hacker-news-api","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fnode-hacker-news-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fnode-hacker-news-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fnode-hacker-news-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fnode-hacker-news-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fraction","download_url":"https://codeload.github.com/fraction/node-hacker-news-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244666586,"owners_count":20490288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-21T08:19:15.899Z","updated_at":"2025-03-21T08:19:17.366Z","avatar_url":"https://github.com/fraction.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js Hacker News API\n\nA Node.js [library](https://www.npmjs.org/package/hacker-news-api) for seamless\nintegration with [Algolia's kickass Hacker News API](https://hn.algolia.com/api).\n\n\n## Installation\n\n```sh\nnpm install hacker-news-api\n```\n\n## Examples\n\nAlmost all methods are chainable, with flexible ordering. Methods are executed\n(as in HTTP requests are made) once a callback function is passed (not all\n  methods accept a callback). Thus, this will always be the last method in the\nchain.\n\n```js\nvar hn = require('hacker-news-api');\n\n// Get recent ask_hn posts, polls, and comments\nhn.ask_hn().poll().comment().recent(function (error, data) {\n  if (error) throw error;\n  console.log(data);\n});\n\n// Get pg's top story and show_hn posts\nhn.author('pg').story().show_hn().top(function (error, data) {\n  if (error) throw error;\n  console.log(data);\n});\n\n// Search for comments and storys containing 'js' before the past week\nhn.comment().story().search('js').before('past_week', function (error, data) {\n  if (error) throw error;\n  console.log(data);\n});\n```\n\n## Chainable Methods\n\n### Tags (OR'ed)\n\nThese tags are logically OR'ed when chained.\n\n- ```ask_hn()```\n- ```comment()```\n- ```poll()```\n- ```pollopt()```\n- ```show_hn()```\n- ```story()```\n\n\n### Tags (AND'ed)\n\nThese tags are logically AND'ed when chained.\n\n- ```author(username)```\n- ```story(id)```\n\n\n### Filters\n\nThese methods take an optional callback function.\n\n- ```recent(cb)```\n- ```top(cb)```\n\n### Time\n\nThese methods take an optional callback function.\n\n- ```before(marker, cb)```\n- ```since(marker, cb)```\n\nThe following are valid inputs for the ```marker```\nparameter:\n\n- **'past_24h'**\n- **'past_week'**\n- **'past_month'**\n- **'forever'**\n\n### Search\n\nThis method takes an optional callback function.\n\n- ```search(query, cb)```\n\n### Settings\n\n- ```hitsPerPage(n)```\n  - _n must be an integer and 1 \u003c= n \u003c= 1000_\n  - _Default is 1000_\n  - _This setting is persistant from one request another_\n- ```page(n)```\n  - _n must be an integer and 0 \u003c= n_\n\n\n## Non-chainable\n\nBy definition these methods are not chainable.\n\n- ```item(id, cb)```\n  - _Get specific item_\n- ```user(username, cb)```\n  - _Get user profile_\n\n\n## API Notes\n\nKeep in mind that Algolia has a rate limit of 10,000 requests per hour from a\nsingle IP. Also, requests have a max of a 1000 hits (results). By default,\n```hitsPerPage``` is to this max (it is configurable however). So for example,\n```author().comment().since()``` called with ```past_month``` will return\nthe first 1000 posts within the last month from the author (user) in question,\nbut there could easily be more than that. You can check this via ```nbHits```\nin the returned JSON, the total number of hits for the query.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraction%2Fnode-hacker-news-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffraction%2Fnode-hacker-news-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraction%2Fnode-hacker-news-api/lists"}