{"id":24056153,"url":"https://github.com/allcentury/hackernews_ruby","last_synced_at":"2025-04-22T23:44:18.845Z","repository":{"id":21620254,"uuid":"24940705","full_name":"allcentury/hackernews_ruby","owner":"allcentury","description":"API Wrapper for Hacker News","archived":false,"fork":false,"pushed_at":"2016-06-24T19:20:18.000Z","size":28,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T17:12:51.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allcentury.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-08T13:00:15.000Z","updated_at":"2024-01-05T18:59:16.000Z","dependencies_parsed_at":"2022-08-21T19:21:00.499Z","dependency_job_id":null,"html_url":"https://github.com/allcentury/hackernews_ruby","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allcentury%2Fhackernews_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allcentury%2Fhackernews_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allcentury%2Fhackernews_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allcentury%2Fhackernews_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allcentury","download_url":"https://codeload.github.com/allcentury/hackernews_ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343848,"owners_count":21415035,"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-01-09T04:59:16.569Z","updated_at":"2025-04-22T23:44:18.827Z","avatar_url":"https://github.com/allcentury.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HackernewsRuby\n\n[![Coverage Status](https://coveralls.io/repos/allcentury/hackernews_ruby/badge.png?branch=master)](https://coveralls.io/r/allcentury/hackernews_ruby?branch=master)\n[![Build Status](https://travis-ci.org/allcentury/hackernews_ruby.svg?branch=master)](https://travis-ci.org/allcentury/hackernews_ruby)\n[![Gem Version](https://badge.fury.io/rb/hackernews_ruby.svg)](http://badge.fury.io/rb/hackernews_ruby)\n\nA wrapper for the new Hacker News API.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hackernews_ruby'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install hackernews_ruby\n\n## Usage\n\nInstantiate a client like so:\n\n```ruby\nclient = HackernewsRuby::Client.new\n```\n\n## Items\n\nItems have the following fields:\n\n[Outlined here form HN](https://github.com/HackerNews/API/blob/master/README.md#items)\n\nField | Description\n------|------------\nid | The item's unique id. Required.\ndeleted | `true` if the item is deleted.\ntype | The type of item. One of \"job\", \"story\", \"comment\", \"poll\", or \"pollopt\".\nby | The username of the item's author.\ntime | Creation date of the item, in [Unix Time](http://en.wikipedia.org/wiki/Unix_time).\ntext | The comment, Ask HN, or poll text. HTML.\ndead | `true` if the item is dead.\nparent | The item's parent. For comments, either another comment or the relevant story. For pollopts, the relevant poll.\nkids | The ids of the item's comments, in ranked display order.\nurl | The URL of the story.\nscore | The story's score, or the votes for a pollopt.\ntitle | The title of the story or poll.\nparts | A list of related pollopts, in display order.\n\nTo get an **item** simply do:\n\n```ruby\nclient.get_item(834129)\n```\nThis will get any item available on the API by ID such as stories, comments, polls and jobs.\n\nSay you wanted the **title** of a story:\n\n```ruby\nstory = client.get_item(8863) #story_id\nstory.title\n=\u003e \"My YC app: Dropbox - Throw away your USB drive\"\n```\n\n## Users\n\nUsers have the following fields:\n\n[Outlined here from HN](https://github.com/HackerNews/API/blob/master/README.md#user://github.com/HackerNews/API/blob/master/README.md#users)\n\nField | Description\n------|------------\nid | The user's unique username. Case-sensitive. Required.\ndelay | Delay in minutes between a comment's creation and its visibility to other users.\ncreated | Creation date of the user, in [Unix Time](http://en.wikipedia.org/wiki/Unix_time).\nkarma | The user's karma.\nabout | The user's optional self-description. HTML.\nsubmitted | List of the user's stories, polls and comments.\n\nSay you wanted to fetch a particular **#user**:\n\n```ruby\nuser = client.get_user('jl') #userid is case sensitive\nuser.about\n=\u003e \"This is a test\"\n```\n\n## Live Data\n\nTo fetch the top 100 stories use **#top_stories**:\n\n```ruby\nstories = client.top_stories\n```\n\nThis will return an array of ID's.  To get each story after that, just use the **#get_item** method like this:\n\n```ruby\nstories = client.top_stories\nstories.each do |story|\n  resp = client.get_item(story)\n  puts resp.title\n  puts resp.score\n  puts resp.url\nend\n```\n\nTo get the most updated Profiles \u0026 Items you can use **#updated**:\n\n```ruby\nupdates = client.updated\nupdates.items\n=\u003e [1212, 1214]\nupdates.profiles\n=\u003e [5653, 25456]\n```\n\nTo get the latest item created you need to call **#max_item**:\n\n```ruby\nlatest = client.max_item\n=\u003e 12343\n```\n\nOr to get contents of the item, just method chain:\n\n```ruby\nlatest = client.max_item\nclient.get_item(latest)\n```\n\n\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/hackernews_ruby/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallcentury%2Fhackernews_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallcentury%2Fhackernews_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallcentury%2Fhackernews_ruby/lists"}