SlideShare a Scribd company logo
Building an API using
GRAPE
Presented By-
Md. Main Uddin Rony
Outlines
What’s Grape?
Basic API
Add Prefix
Add Namespace
Add Module
Add version
Parameters
Declared
Using Helpers
Routes
Raise Exception
Exception Handling
API Format
Useful Resources
What’s Grape?
Generalized
Rapid
APIs
Erector
An opinionated
micro-framework
for creating RESTful
APIs in Ruby
•Powerful API framework
•Designed to run on Rack Application
•To fit into Sinatra and Rails Application
Installation
‘ gem install grape’
Or
gem 'grape‘ // using Bundler
Run bundle install.
Work with Rails
Place API files into and modify
Modify
Basic API
Add Prefix
Add Namespace
Add Namespace (Contd.)
Namespaces allow parameter definitions and apply to every method within the namespace.
Add Namespace(Contd.)
We can define a route parameter as namespace using
Add Module
If we want to mount on a path inside the mounted API itself:
Add Version
Add Version(Contd.)
Four Strategies:
❑ Path → →
❑ Header → →
❑ Param → →
→
❑ Accept-Version Header →
→
Parameters
Request parameters are available through the ”params” hash object.
Parameters are automatically populated from the request body on POST and PUT for form input, JSON and XML content-types.
Declared
Grape allows you to access only the parameters that have been declared by your ’params’ block. It filters out the params that have been passed, but are not
allowed.
Use Helpers
Routes
We can define requirements for your named route parameters using regular expressions on namespace or endpoint.
Raise Exception
We can abort the execution of an API method by raising errors with
We can also return JSON formatted objects by raising error! and passing a hash instead of a message.
Exception Handling
Grape can be told to rescue all exceptions and return them in the API format.
You can also rescue specific exceptions.
API Formats
If we do not specify any, Grape will support XML, JSON, BINARY, and TXT content-types. The default format is :txt
Advantages
1. Designed to run on rack or existing application frameworks such as Rails and Sinatra
2. It has built-in support for common conventions, including multiple formats, subdomain/prefix
restriction.
3. Versioning is very easy.
4. A lightweight framework which is loosely coupled with other application frameworks.
Useful Resources
1. https://github.com/intridea/grape
2. https://groups.google.com/forum/?fromgroups#!forum/ruby-grape
3. http://intridea.github.io/grape/docs/index.html
4. https://github.com/intridea/grape/wiki
5. http://confreaks.tv/videos/rubyconf2010-the-grapes-of-rapid
Questions??
THANK YOU!!!!

More Related Content

PPTX
Big data processing with Apache Spark and Oracle Database
PDF
Graph Data Science DEMO for fraud analysis
PDF
Hexagonal architecture message-oriented software design
PDF
Spark Summit EU talk by Ted Malaska
PPTX
RDBMS to NoSQL. An overview.
PPTX
Apache Hadoop
PPTX
Introduction to Scala
PPTX
Introduction to Content Delivery Networks
Big data processing with Apache Spark and Oracle Database
Graph Data Science DEMO for fraud analysis
Hexagonal architecture message-oriented software design
Spark Summit EU talk by Ted Malaska
RDBMS to NoSQL. An overview.
Apache Hadoop
Introduction to Scala
Introduction to Content Delivery Networks

What's hot (20)

PDF
Advanced backup methods (Postgres@CERN)
PDF
Developing RESTful Web APIs with Python, Flask and MongoDB
PPTX
inheritance
PPTX
The Elastic ELK Stack
PDF
Découverte de Elastic search
PPTX
Apache Spark Architecture
PDF
Spark SQL
PDF
Data modeling for Elasticsearch
PDF
Analyzing Flight Delays with Apache Spark, DataFrames, GraphFrames, and MapR-DB
PDF
Postgres Vision 2018: WAL: Everything You Want to Know
 
PPTX
How to Actually Tune Your Spark Jobs So They Work
PPTX
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
PDF
Logstash-Elasticsearch-Kibana
PPTX
Introduction to Apache Spark
PDF
Introduction to rust: a low-level language with high-level abstractions
PPTX
Real-time Stream Processing with Apache Flink
PPTX
Mongo db 최범균
PDF
Rust system programming language
PPT
온톨로지 추론 개요
PPTX
Programming in Spark using PySpark
Advanced backup methods (Postgres@CERN)
Developing RESTful Web APIs with Python, Flask and MongoDB
inheritance
The Elastic ELK Stack
Découverte de Elastic search
Apache Spark Architecture
Spark SQL
Data modeling for Elasticsearch
Analyzing Flight Delays with Apache Spark, DataFrames, GraphFrames, and MapR-DB
Postgres Vision 2018: WAL: Everything You Want to Know
 
How to Actually Tune Your Spark Jobs So They Work
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
Logstash-Elasticsearch-Kibana
Introduction to Apache Spark
Introduction to rust: a low-level language with high-level abstractions
Real-time Stream Processing with Apache Flink
Mongo db 최범균
Rust system programming language
온톨로지 추론 개요
Programming in Spark using PySpark
Ad

Similar to Grape(Ruby on Rails) (20)

PPTX
Ruby On Grape
PPTX
Building an API using Grape
PDF
The Grapes of Rapid (RubyConf 2010)
PDF
Restful API On Grape
PDF
Rapid-ruby-api-on-grape
PPTX
Ruby on Grapes. Why did we choose Grape and why I would choose it again
PDF
Finding Restfulness - Madrid.rb April 2014
PPTX
Building RESTful APIs w/ Grape
PDF
Lightning Talk: From Sinatra to Grape.pdf
PDF
APIs for mobile
KEY
2011 a grape odyssey
PPT
Creating a World-Class RESTful Web Services API
PDF
Jordi Romero Api for-the-mobile-era
PDF
Making and Breaking Web Services with Ruby
 
PDF
Design Web Api
KEY
I can haz HTTP - Consuming and producing HTTP APIs in the Ruby ecosystem
PDF
Api presentation
ODP
Grape golilath
PDF
Api Design and More (Friday Training at Itnig)
PDF
Creating a RESTful api without losing too much sleep
Ruby On Grape
Building an API using Grape
The Grapes of Rapid (RubyConf 2010)
Restful API On Grape
Rapid-ruby-api-on-grape
Ruby on Grapes. Why did we choose Grape and why I would choose it again
Finding Restfulness - Madrid.rb April 2014
Building RESTful APIs w/ Grape
Lightning Talk: From Sinatra to Grape.pdf
APIs for mobile
2011 a grape odyssey
Creating a World-Class RESTful Web Services API
Jordi Romero Api for-the-mobile-era
Making and Breaking Web Services with Ruby
 
Design Web Api
I can haz HTTP - Consuming and producing HTTP APIs in the Ruby ecosystem
Api presentation
Grape golilath
Api Design and More (Friday Training at Itnig)
Creating a RESTful api without losing too much sleep
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

Grape(Ruby on Rails)