{"id":20049884,"url":"https://github.com/kymmt90/hatenablog","last_synced_at":"2025-04-05T06:05:09.540Z","repository":{"id":42187238,"uuid":"43822608","full_name":"kymmt90/hatenablog","owner":"kymmt90","description":"A Ruby gem for Hatena Blog AtomPub API","archived":false,"fork":false,"pushed_at":"2025-01-11T10:13:09.000Z","size":231,"stargazers_count":41,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T05:04:24.287Z","etag":null,"topics":["api-client","hatena","hatena-blog","ruby-client","ruby-gem"],"latest_commit_sha":null,"homepage":"","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/kymmt90.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-10-07T14:45:37.000Z","updated_at":"2025-01-11T10:13:12.000Z","dependencies_parsed_at":"2024-01-06T04:21:28.973Z","dependency_job_id":"f4a82ba5-e65e-4408-a9d3-a0d843216db1","html_url":"https://github.com/kymmt90/hatenablog","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kymmt90%2Fhatenablog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kymmt90%2Fhatenablog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kymmt90%2Fhatenablog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kymmt90%2Fhatenablog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kymmt90","download_url":"https://codeload.github.com/kymmt90/hatenablog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294538,"owners_count":20915340,"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":["api-client","hatena","hatena-blog","ruby-client","ruby-gem"],"created_at":"2024-11-13T11:53:07.665Z","updated_at":"2025-04-05T06:05:09.523Z","avatar_url":"https://github.com/kymmt90.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hatenablog\n\n[![Gem Version](https://badge.fury.io/rb/hatenablog.svg)](https://badge.fury.io/rb/hatenablog) [![Build Status](https://github.com/kymmt90/hatenablog/workflows/build/badge.svg)](https://github.com/kymmt90/hatenablog/actions?workflow=build)\n[![Code Climate](https://codeclimate.com/github/kymmt90/hatenablog/badges/gpa.svg)](https://codeclimate.com/github/kymmt90/hatenablog)\n[![Test Coverage](https://codeclimate.com/github/kymmt90/hatenablog/badges/coverage.svg)](https://codeclimate.com/github/kymmt90/hatenablog/coverage)\n\n\u003e A library for Hatena Blog AtomPub API\n\nThis gem supports following operations through OAuth 1.0a or Basic authentication:\n\n- Get blog feeds, entries and categories\n- Post blog entries\n- Update blog entries\n- Delete blog entries\n\n## Installation\n\n### Install the gem\n\nAdd this line to your application's Gemfile:\n\n```\ngem 'hatenablog'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install hatenablog\n```\n\n### Get OAuth credentials\n\nYou need to set up OAuth 1.0a keys and tokens before using this gem.\n\n#### 1. Get consumer key and consumer key secret\n\nAccess [Hatena application registoration page](http://developer.hatena.ne.jp/) and get your application consumer key.\n\n#### 2. Get your access token and access token secret\n\nExecute this command:\n\n```\n$ get_hatena_oauth_access_token \u003cyour consumer key\u003e \u003cyour consumer secret\u003e\nVisit this website and get the PIN: https://www.hatena.com/oauth/authorize?oauth_token=XXXXXXXXXXXXXXXXXXXX\nEnter the PIN: \u003cyour PIN\u003e [Enter]\nAccess token: \u003cyour access token\u003e\nAccess token secret: \u003cyour access token secret\u003e\n```\n\n#### 3. [Optional] Set up the YAML configuration file\n\nThe default configuration file name is `config.yml`:\n\n```yml\nconsumer_key: \u003cHatena application consumer key\u003e\nconsumer_secret: \u003cHatena application consumer secret\u003e\naccess_token: \u003cHatena application access token\u003e\naccess_token_secret: \u003cHatena application access token secret\u003e\nuser_id: \u003cHatena user ID\u003e\nblog_id: \u003cHatenablog ID\u003e\n```\n\nThis file accepts ERB syntax.\n\n```yml\nconsumer_key: \u003c%= ENV['CONSUMER_KEY'] %\u003e\nconsumer_secret: \u003c%= ENV['CONSUMER_SECRET'] %\u003e\naccess_token: \u003c%= ENV['ACCESS_TOKEN'] %\u003e\naccess_token_secret: \u003c%= ENV['ACCESS_TOKEN_SECRET'] %\u003e\nuser_id: \u003c%= ENV['USER_ID'] %\u003e\nblog_id: \u003c%= ENV['BLOG_ID'] %\u003e\n```\n\n`blog_id` means your Hatena Blog domain, like \"example-user.hatenablog.com\".\n\nYou also can set these configurations in your code as described in [the below section](#factories).\n\n### [Optional] Get Basic authentication credentials\nIf you want to use Basic authentication, visit `http://blog.hatena.ne.jp/#{user_id}/#{blog_id}/config/detail`\nand check your API key and set up `config.yml` like the following.\n\n```yml\nauth_type: basic\napi_key: \u003c%= ENV['API_KEY'] %\u003e\nuser_id: \u003c%= ENV['USER_ID'] %\u003e\nblog_id: \u003c%= ENV['BLOG_ID'] %\u003e\n```\n\n## Usage\n\n```ruby\nrequire 'hatenablog'\n\n# Read the configuration from 'config.yml'\nHatenablog::Client.create do |blog|\n  # Get each entry's content\n  blog.entries.each do |entry|\n    puts entry.content\n  end\n\n  # Post new entry\n  posted_entry = blog.post_entry(\n    'Entry Title',\n    'This is entry contents', # markdown form\n    ['Test', 'Programming']   # categories\n  )\n\n  # Update entry\n  updated_entry = blog.update_entry(\n    posted_entry.id,\n    'Revised Entry Title',\n    posted_entry.content,\n    posted_entry.categories\n  )\n\n  # Delete entry\n  blog.delete_entry(updated_entry.id)\nend\n```\n\n## API\n\n### Factories\n\nYou can create the client from the configuration file.\n\n```ruby\n# Create the client from \"./config.yml\"\nclient = Hatenablog::Client.create\n\n# Create the client from the specified configuration\nclient = Hatenablog::Client.create('../another_config.yml')\n\nHatenablog::Client.create do |client|\n  # Use the client in the block\nend\n```\n\nYou can also create the client with a block for configurations.\n\n```ruby\nclient = Hatenablog::Client.new do |config|\n  config.consumer_key        = 'XXXXXXXXXXXXXXXXXXXX'\n  config.consumer_secret     = 'XXXXXXXXXXXXXXXXXXXX'\n  config.access_token        = 'XXXXXXXXXXXXXXXXXXXX'\n  config.access_token_secret = 'XXXXXXXXXXXXXXXXXXXX'\n  config.user_id             = 'example-user'\n  config.blog_id             = 'example-user.hatenablog.com'\nend\n```\n\n### Blog\n\n```ruby\nclient.title       # Get the blog title\nclient.author_name # Get the blog author name\n```\n\n### Feeds\n\n```ruby\nfeed = client.next_feed # Get the first feed when no argument is passed\nfeed.uri\nfeed.next_uri    # The next feed URI\nfeed.title\nfeed.author_name\nfeed.updated     # Updated datetime\n\nfeed.entries # entries in the feed\nfeed.each_entry do |entry|\n  # ...\nend\nfeed.has_next? # true if the next page exists\nnext_feed = client.next_feed(feed)\n```\n\n### Entries\n\n```ruby\nclient.get_entry('0000000000000000000') # Get the entry specifed by its ID\nclient.entries     # Get blog entries in the first page\nclient.entries(1)  # Get blog entries in the first and the second page\nclient.all_entries # Get all entries in the blog\n\nentry = client.post_entry(\n  'Example Title',                  # title\n  'This is the **example** entry.', # content\n  ['Ruby', 'Rails'],                # categories\n  'yes',                            # draft\n  '2022-04-11T15:43:20+09:00'       # updated\n)\nentry.id\nentry.uri\nentry.edit_uri\nentry.author_name\nentry.title             #=\u003e 'Example Title'\nentry.content           #=\u003e 'This is the **example** entry.'\nentry.formatted_content #=\u003e '\u003cp\u003eThis is the \u003cstrong\u003eexample\u003c/strong\u003e entry.\u003c/p\u003e'\nentry.draft             #=\u003e 'yes'\nentry.draft?            #=\u003e true\nentry.categories        #=\u003e ['Ruby', 'Rails']\nentry.updated           # Updated datetime\n\nclient.update_entry(\n  entry.id,\n  entry.title,\n  'This is the **modified** example entry.',\n  entry.categories,\n  'no'\n)\nclient.delete_entry(entry.id)\n```\n\n### Categories\n\n```ruby\ncategories = client.categories # Get categories registered in the blog\ncategories.each do |cat|\n  puts cat\nend\n\n# When categories are fixed, you can only use those categories for your entries.\n# ref: https://tools.ietf.org/html/rfc5023#section-7.2.1.1\ncategories.fixed?\n```\n\n## Contributing\n\n1. Create your feature branch (`git checkout -b my-new-feature`)\n2. Commit your changes (`git commit -am 'Add some feature'`)\n3. Push to the branch (`git push origin my-new-feature`)\n4. Create a new Pull Request\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkymmt90%2Fhatenablog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkymmt90%2Fhatenablog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkymmt90%2Fhatenablog/lists"}