{"id":16956989,"url":"https://github.com/jgraichen/restify","last_synced_at":"2025-08-02T13:06:18.704Z","repository":{"id":17512043,"uuid":"20299978","full_name":"jgraichen/restify","owner":"jgraichen","description":"Restify is a parallel and pipelined Hypermedia API client","archived":false,"fork":false,"pushed_at":"2025-05-19T22:26:28.000Z","size":369,"stargazers_count":9,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-22T12:24:02.658Z","etag":null,"topics":["asynchronous","future","hateoas","http","json","promise","rest","rest-client","restful","restify","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgraichen.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,"zenodo":null}},"created_at":"2014-05-29T16:16:46.000Z","updated_at":"2025-06-26T13:47:34.000Z","dependencies_parsed_at":"2025-05-02T07:19:32.283Z","dependency_job_id":"f4812d9b-ed90-4015-a58a-8b1743050737","html_url":"https://github.com/jgraichen/restify","commit_stats":{"total_commits":316,"total_committers":7,"mean_commits":"45.142857142857146","dds":0.5917721518987342,"last_synced_commit":"e2031196b8a3d1bc303d536a4b07f7c82a3c5310"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/jgraichen/restify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frestify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frestify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frestify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frestify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgraichen","download_url":"https://codeload.github.com/jgraichen/restify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frestify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267520336,"owners_count":24100823,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asynchronous","future","hateoas","http","json","promise","rest","rest-client","restful","restify","ruby"],"created_at":"2024-10-13T22:16:34.341Z","updated_at":"2025-08-02T13:06:18.671Z","avatar_url":"https://github.com/jgraichen.png","language":"Ruby","readme":"# Restify\n\n[![Gem Version](https://img.shields.io/gem/v/restify?logo=ruby)](https://rubygems.org/gems/restify)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/jgraichen/restify/test.yml?logo=github)](https://github.com/jgraichen/restify/actions)\n[![Code Quality](https://codebeat.co/badges/368f8033-bd76-48bc-9777-85f1d4befa94)](https://codebeat.co/projects/github-com-jgraichen-restify-main)\n\nRestify is an hypermedia REST client that does parallel, concurrent and keep-alive requests by default.\n\nRestify scans Link headers and returned resource for links and relations to other resources, represented as RFC6570 URI Templates, and exposes those to the developer.\n\nRestify can be used to consume hypermedia REST APIs (like GitHubs), to build a site-specific library or to use within your own backend services.\n\nRestify is build upon the following libraries:\n\n* [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby)\n* [addressable](https://github.com/sporkmonger/addressable)\n* [typhoeus](https://github.com/typhoeus/typhoeus)\n\nThe HTTP adapters are mostly run in a background thread and may not survive mid-application forks.\n\nRestify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:\n\n* JSON\n* MessagePack\n\nLinks are extracted from\n\n* HTTP Link header\n* Github-style relations in payloads\n\n## Installation\n\nAdd it to your Gemfile:\n\n```ruby\ngem 'restify', '~\u003e 2.0'\n```\n\nOr install it manually:\n\n```console\ngem install restify\n```\n\n## Usage\n\nCreate new Restify object. It essentially means to request some start-resource usually the \"root\" resource:\n\n```ruby\nclient = Restify.new('https://api.github.com').get.value\n# =\u003e {\"current_user_url\"=\u003e\"https://api.github.com/user\",\n#     \"current_user_authorizations_html_url\"=\u003e\"https://github.com/settings/connections/applications{/client_id}\",\n# ...\n#     \"repository_url\"=\u003e\"https://api.github.com/repos/{owner}/{repo}\",\n# ...\n```\n\nWe are essentially requesting `'http://api.github.com'` via HTTP `get`. `get` is returning a `Promise`, similar to Java's `Future`. The `value` call resolves the returned `Promise` by blocking the thread until the resource is actually there. `value!` will additionally raise errors instead of returning `nil`. You can chain handlers using the `then` method. This allows you to be build a dependency chain that will be executed when the last promise is needed.\n\nAs we can see GitHub returns us a field `repository_url` with a URI template. Restify automatically scans for `*_url` fields in the JSON response and exposes these as relations. It additionally scans the HTTP Header field `Link` for relations like pagination.\n\nWe can now use the relations to navigate from resource to resource like a browser from one web page to another page.\n\n```ruby\nrepositories = client.rel(:repository)\n# =\u003e #\u003cRestify::Relation:0x00000005548968 @context=#\u003cRestify::Context:0x007f6024066ae0 @uri=#\u003cAddressable::URI:0x29d8684 URI:https://api.github.com\u003e\u003e, @template=#\u003cAddressable::Template:0x2aa44a0 PATTERN:https://api.github.com/repos/{owner}/{repo}\u003e\u003e\n```\n\nThis gets us the relation named `repository` that we can request now. The usual HTTP methods are available on a relation:\n\n```ruby\ndef get(params, params:, headers:, **)\ndef head(params, params:, headers:, **)\ndef delete(params, params:, headers:, **)\n\ndef put(data = nil, params:, headers:, **)\ndef post(data = nil, params:, headers:, **)\ndef patch(data = nil, params:, headers:, **)\n```\n\nURL templates can define some parameters such as `{owner}` or `{repo}`. They will be expanded from the `params` given to the HTTP method.\n\nNow send a GET request with some parameters to request a specific repository:\n\n```ruby\nrepo = repositories.get({owner: 'jgraichen', repo: 'restify'}).value\n```\n\nNow fetch a list of commits for this repo and get this first one:\n\n```ruby\ncommit = repo.rel(:commits).get.value.first\n```\n\nAnd print it:\n\n```ruby\nputs \"Last commit: #{commit['sha']}\"\nputs \"By #{commit['commit']['author']['name']} \u003c#{commit['commit']['author']['email']}\u003e\"\nputs \"#{commit['commit']['message']}\"\n```\n\nSee commented example in main spec [`spec/restify_spec.rb`](https://github.com/jgraichen/restify/blob/master/spec/restify_spec.rb#L100) or in the `examples` directory.\n\n## Contributing\n\n1. [Fork it](http://github.com/jgraichen/restify/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit specs for your feature so that I do not break it later\n4. Commit your changes (`git commit -am 'Add some feature'`)\n5. Push to the branch (`git push origin my-new-feature`)\n6. Create new Pull Request\n\n## License\n\nCopyright (C) 2014-2025 Jan Graichen\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frestify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgraichen%2Frestify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frestify/lists"}