API Resources for Ruby Developers
Ruby is a popular dynamically typed language that really gained traction in the mid 2000s for developing MVC websites using the Ruby on Rails (RoR) framework. While less popular with modern APIs and Single Page Apps, you’ll still see APIs being built with Ruby in the wild.
Ruby is an easy language to get started with for web development and shares many features with Python. The RoR framework is very opinionated with batteries included which can be very useful for new entrants to web development.
Like Python, Ruby suffers from the Global Interpreter Lock (GIL) issues as famously seen with Twitter trying to scale Ruby and eventually switched to Scala. While developers can now write decent performing non-blocking code. Developers looking to build CPU bound parallel applications should probably look at some other languages.
Ruby has a very active open source community which can make documentation more difficult but provides, a much lower cost to getting started relative to some other communities like .NET.
Ruby Background
- History on Wikipedia
- Principle of Least Astonishment: This is the core philosophy of Ruby.
Tutorials on Creating Restful API
Most RESTful APIs are created using a framework of some sort, often it is same frameworks that are used for Web applications. The tutorials below are organized by framework.
-
Ruby on Rails
The most popular framework for Ruby.
-
Grape
A framework designed for creating REST like APIs in Ruby.
-
Sinatra
- How to create APIs on Sinatra
- Use Sinatra to implement REST API
- Sinatra-Rest-API - A generator that creates RESTful API routes for a CRUD app based on your data schema.
Tutorials for Creating GraphQL APIs
- Official tutorial from HowToGraphql.com
- Ruby GraphQL server example
- Implement a GraphQL API in Rails
- A multi-part tutorial for GraphQL on Rails
Deploying Ruby APIs
-
Heroku
-
AWS
-
Azure
-
Google App Engine
Useful Libraries aka Gems, and Resources
Ruby libraries are called gems, and are managed by
-
Documentation
- swagger-docs - Generates swagger-ui json files for Rails APIs with a simple DSL.
- ruby-swagger - A super-duper-simple library to read or create Swagger API documents.
- grape-swagger - Add OAPI/swagger v2.0 compliant documentation to your grape API
-
Authentication
- brypt - a Ruby binding for the OpenBSD bcrypt() password hashing algorithm
- ruby-jwt - A pure ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard.
- OmniAuth - A library that standardizes multi-provider authentication utilizing Rack middleware.
- devise-token-auth - Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
- api-auth - HMAC authentication for Rails and HTTP Clients.
- Knock - Seamless JWT authentication for Rails API.
- Doorkeeper - An OAuth2 provider for Rails.
- OAuth2 - A Ruby wrapper for the OAuth 2.0 protocol.
-
CORS
- rack-cors - A middleware for Rack that supports CORS.
-
JSON
- ruby json implementation
- multi_json
- Jsonite - A tiny, HAL-compliant JSON presenter for your APIs.
-
Utilities
- httparty
- faraday - Simple, but flexible HTTP client library, with support for multiple backends.
- concurrent-ruby - Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
-
Databases, Query Builder and ORMs
- sequel
- rails-db
- pg - PostgreSQL driver.
- sqlite3
- mysql2
- activerecord - Already part of the Rails framework.
- activemodel - Also part of the Rails framework.
- arel
-
Testing
-
RESTful APIs
- Blanket - An API wrapper.
- Crepe - Lightweight API framework.
- Grape - An opinionated micro-framework for creating REST-like APIs in Ruby.
- Her - An ORM that maps REST resources to Ruby objects. Designed to build applications that are powered by a RESTful API instead of a database.
- jbuilder - Create JSON structures via a Builder-style DSL.
- jsonapi-rb – Efficient and convenient JSON API (de)serialization library.
- JSONAPI::Resources - JSONAPI::Resources provides a framework for developing a server
- JSONAPI::Utils - JSONAPI::Utils is built on top of JSONAPI::Resources taking advantage of its resource-driven style and bringing an easy way to build modern JSON APIs.
- Pliny - Opinionated template Sinatra app for writing excellent APIs in Ruby.
- rabl - General ruby templating with json, bson, xml, plist and msgpack support.
- Rails::API - Rails for API only applications.
- Roar - Parse and render REST API documents using representers.
- Spyke - Interact with REST services in an ActiveRecord-like manner.
- Version Cake - An unobtrusive way to version APIs in your Rails app.
- versionist - A plugin for versioning Rails based RESTful APIs.
-
GraphQL
- GraphQL-Ruby - A Ruby implementation.
- GraphQL
- graphql-batch – A query batching executor.
- graphql-client - A library for declaring, composing and executing GraphQL queries.
- graphql-guard - A simple field-level authorization.`
-
WebSockets
- AnyCable - Polyglot replacement for Ruby WebSocket servers with Action Cable protocol.
- Em-websocket - EventMachine based WebSocket server.
- Faye-websocket-ruby - Standards-compliant WebSocket client and server.
- Websocket-driver-ruby - WebSocket protocol handler with pluggable I/O.
- Websocket-ruby - Universal Ruby library to handle WebSocket protocol.
- Scorched - Light-weight web framework for Ruby.
- Firehose - Build realtime Ruby web applications. Created by the fine folks at Poll Everywhere.
- Slanger - Open Pusher implementation compatible with Pusher libraries.
- render_sync - Real-time Rails Partials.
- websocket-rails - Plug and play websocket support for ruby on rails.