{"id":15692110,"url":"https://github.com/nejdetkadir/dev-ruby","last_synced_at":"2025-05-07T23:48:05.753Z","repository":{"id":40291260,"uuid":"492582172","full_name":"nejdetkadir/dev-ruby","owner":"nejdetkadir","description":"Ruby bindings for dev.to API","archived":false,"fork":false,"pushed_at":"2022-05-16T20:01:43.000Z","size":41,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T12:06:13.806Z","etag":null,"topics":["api-client","blogs","devto","ruby","ruby-client","ruby-gem"],"latest_commit_sha":null,"homepage":"https://developers.forem.com/api/","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/nejdetkadir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-15T19:21:08.000Z","updated_at":"2024-01-19T17:33:24.000Z","dependencies_parsed_at":"2022-08-09T16:34:23.934Z","dependency_job_id":null,"html_url":"https://github.com/nejdetkadir/dev-ruby","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fdev-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fdev-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fdev-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fdev-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nejdetkadir","download_url":"https://codeload.github.com/nejdetkadir/dev-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973624,"owners_count":21834105,"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","blogs","devto","ruby","ruby-client","ruby-gem"],"created_at":"2024-10-03T18:29:20.657Z","updated_at":"2025-05-07T23:48:05.732Z","avatar_url":"https://github.com/nejdetkadir.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/dev_ruby.svg)](https://badge.fury.io/rb/dev_ruby)\n![test](https://github.com/nejdetkadir/dev-ruby/actions/workflows/test.yml/badge.svg?branch=main)\n![rubocop](https://github.com/nejdetkadir/dev-ruby/actions/workflows/rubocop.yml/badge.svg?branch=main)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\n![Ruby Version](https://img.shields.io/badge/ruby_version-\u003e=_2.7.0-blue.svg)\n\n# DevRuby\nRuby bindings for DEV API\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'dev_ruby', github: 'nejdetkadir/dev-ruby', branch: 'main'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install dev_ruby\n\n## Configuration\n```ruby\nDevRuby.configure do |config|\n  config.logger = ::Logger.new($stdout).tap { |d| d.level = Logger::DEBUG }\n  config.log_api_bodies = true\n  config.per_page = 20\nend\n```\n\n## Usage\nTo access the API, you'll need to create a DevRuby::Client and pass in your API key. You can find your API key at [https://developers.forem.com/api](https://developers.forem.com/api)\n\n```ruby\nclient = DevRuby::Client.new(api_key: ENV['DEV_API_KEY'])\n```\nThe client then gives you access to each of the resources.\n\n## Resources\nThe gem maps as closely as we can to the DEV API so you can easily convert API examples to gem code.\n\nResponses are returning as objects like `DevRuby::Objects::Article` with using [dry-monads](https://github.com/dry-rb/dry-monads) gem for easly error handling. Having types like `DevRuby::Objects::Article` is handy for understanding what type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way.\n\n```ruby\n# Sample request with dry-monads\n\nclient = DevRuby::Client.new(api_key: ENV['DEV_API_KEY'])\n\noperation = client.articles.create(title: 'My Article',\n                                   body: 'This is my article')\n\nif operation.success?\n  article = operation.success\n\n  puts 'Article created successfully'\n  puts \"Article ID: #{article.id}\"\nend\n\nif operation.failure?\n  errors = operation.failure\n\n  puts 'Article creation failed'\n  puts \"Error: #{errors}\"\nend\n\noperation.value! # Returns the article if successful or return error if not successful\n```\n\n## Pagination\nSome endpoints return pages of results. The result object will have a data key to access the results, as well as metadata like next_page and prev_page for retrieving the next and previous pages. You may also specify the\n\n```ruby\ncollection = client.articles.published.value!\n#=\u003e DevRuby::Collection\n\ncollection.data\n#=\u003e [#\u003cDevRuby::Objects::Article\u003e, #\u003cDevRuby::Objects::Article\u003e]\n\ncollection.data.count\n#=\u003e 3\n\ncollection.next_page\n#=\u003e \"3\"\n\ncollection.prev_page\n#=\u003e \"1\"\n\n# Retrieve the next page\nclient.articles.published(per_page: 100, page: collection.next_page)\n#=\u003e DevRuby::Collection\n```\n\n## Articles\n```ruby\n# This endpoint allows the client to retrieve a list of articles.\n# By default it will return featured, published articles ordered by descending popularity.\ncollection = client.articles.published.value! # per_page is optional, defaults to 20.\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to create a new article.\narticle = client.articles.create(title: 'Hello, World!',\n                                  published: true,\n                                  body_markdown: 'Hello DEV, this is my first post',\n                                  tags: %w[discuss help],\n                                  series: 'Hello series').value!\n#=\u003e DevRuby::Objects::Article\n\n# This endpoint allows the client to retrieve a list of articles. ordered by descending publish date.\ncollection = client.articles.latest_published.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a single published article given its id.\narticle = client.articles.find('123456').value!\n#=\u003e DevRuby::Objects::Article\n\n# This endpoint allows the client to update an existing article.\narticle = client.articles.update(id: '123456',\n                                 title: 'Hello, World!').value!\n#=\u003e DevRuby::Objects::Article\n\n# This endpoint allows the client to retrieve a single published article given its path.\narticle = client.articles.find_by_path(username: 'nejdetkadir', slug: 'hello-world').value!\n#=\u003e DevRuby::Objects::Article\n\n# This endpoint allows the client to retrieve a list of published articles on behalf of an authenticated user.\n# Published articles will be in reverse chronological publication order.\ncollection = client.articles.me.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of published articles on behalf of an authenticated user.\n# Published articles will be in reverse chronological publication order\ncollection = client.articles.me_published.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of unpublished articles on behalf of an authenticated user.\n# Unpublished articles will be in reverse chronological creation order.\ncollection = client.articles.me_unpublished.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of all articles on behalf of an authenticated user.\n# It will return both published and unpublished articles with pagination.\n# Unpublished articles will be at the top of the list in reverse chronological creation order. Published articles will follow in reverse chronological publication order\ncollection = client.articles.me_all.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of articles that are uploaded with a video.\n# It will only return published video articles ordered by descending popularity.\ncollection = client.articles.videos.value!\n#=\u003e DevRuby::Collection\n```\n\n## Comments\n```ruby\n# This endpoint allows the client to retrieve all comments belonging to an article or podcast episode as threaded conversations.\n# It will return the all top level comments with their nested comments as threads. See the format specification for further details.\ncollection = client.comments.all.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a comment as well as his descendants comments.\n# It will return the required comment (the root) with its nested descendants as a thread.\n# See the format specification for further details.\ncomment = client.comments.find('123456').value!\n#=\u003e DevRuby::Objects::Comment\n```\n\n## Follows\n```ruby\n# This endpoint allows the client to retrieve a list of the tags they follow.\ncollection = client.follows.followed_tags.value!\n#=\u003e DevRuby::Collection\n```\n\n## Followers\n```ruby\n# This endpoint allows the client to retrieve a list of the followers they have.\ncollection = client.followers.all.value!\n#=\u003e DevRuby::Collection\n```\n\n## Listings\n```ruby\n# This endpoint allows the client to retrieve a list of listings.\n# By default it will return published listings ordered by descending freshness.\ncollection = client.listings.published.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to create a new listing.\n# The user creating the listing or the organization on which behalf the user is creating for need to have enough credits for this operation to be successful. The server will prioritize the organization's credits over the user's credits.\nlisting = client.listings.create(title: 'ACME Conference',\n                                 body_markdown: 'Awesome conference',\n                                 category: 'cfp',\n                                 tags: %w[events]).value!\n#=\u003e DevRuby::Objects::Listing\n\n# This endpoint allows the client to retrieve a list of listings belonging to the specified category.\n# By default it will return published listings ordered by descending freshness.\ncollection = client.listings.published_by_category(category: 'cfp').value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a single listing given its id.\n# An unpublished listing is only accessible if authentication is supplied and it belongs to the authenticated user.\nlisting = client.listings.find('123456').value!\n#=\u003e DevRuby::Objects::Listing\n\n# This endpoint allows the client to update an existing listing.\narticle = client.listings.update(id: '123456', action: 'bump').value!\n#=\u003e DevRuby::Objects::Listing\n```\n\n## Organizations\n```ruby\n# This endpoint allows the client to retrieve a single organization by their username.\norganization = client.organizations.find_by_username('nejdetkadir').value!\n#=\u003e DevRuby::Objects::Organization\n\n# This endpoint allows the client to retrieve a list of users belonging to the organization\ncollection = client.organizations.all_users_by_username(username: 'nejdetkadir').value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of listings belonging to the organization\ncollection = client.organizations.all_listings_by_username(username: 'nejdetkadir').value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of Articles belonging to the organization \ncollection = client.organizations.all_articles_by_username(username: 'nejdetkadir').value!\n#=\u003e DevRuby::Collection\n```\n\n## Podcast Episodes\n```ruby\n# This endpoint allows the client to retrieve a list of podcast episodes.\ncollection = client.podcast_episodes.published.value!\n#=\u003e DevRuby::Collection\n```\n\n## Readinglists\n```ruby\n# This endpoint allows the client to retrieve a list of readinglist reactions along with the related article for the authenticated user.\n# Reading list will be in reverse chronological order base on the creation of the reaction.\ncollection = client.readinglists.all.value!\n#=\u003e DevRuby::Collection\n```\n\n## Tags\n```ruby\n# This endpoint allows the client to retrieve a list of tags that can be used to tag articles.\n# It will return tags ordered by popularity.\ncollection = client.tags.all.value!\n#=\u003e DevRuby::Collection\n\n# This endpoint allows the client to retrieve a list of the tags they follow.\ncollection = client.tags.followed_tags.value!\n#=\u003e DevRuby::Collection\n```\n\n## Users\n```ruby\n# This endpoint allows the client to retrieve a list of published articles on behalf of an authenticated user.\nuser = client.users.me.value!\n#=\u003e DevRuby::Objects::User\n\n# This endpoint allows the client to retrieve a single user, either by id or by the user's username\nuser = client.users.find('123456').value!\n#=\u003e DevRuby::Objects::User\n\ninvitation = client.users.invite_user(email: 'user@example.com', name: 'string').value!\n#=\u003e true\n```\n\n## Profile Images\n```ruby\nprofile_image = client.profile_images.find_by_username('nejdetkadir').value!\n#=\u003e DevRuby::Objects::ProfileImage\n```\n\n## Development\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at https://github.com/nejdetkadir/dev-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/nejdetkadir/dev-ruby/blob/main/CODE_OF_CONDUCT.md).\n\n## License\nThe gem is available as open source under the terms of the [MIT License](LICENSE).\n\n## Code of Conduct\nEveryone interacting in the DevRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nejdetkadir/dev-ruby/blob/main/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnejdetkadir%2Fdev-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnejdetkadir%2Fdev-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnejdetkadir%2Fdev-ruby/lists"}