SlideShare a Scribd company logo
API
RAML API Designing Basics
• Introduction
• RAML API Schema
• Root
• Resources
• Methods
• URI Parameters
• Query Parameters
• Responses
Introduction
What is RAML ?
• RAML : RESTful API Modeling Language.
• Non-proprietary, vendor-neutral open spec.
• Aims to help current API ecosystem and solve immediate problems,
and then gently encourage ever-better API patterns.
Why RAML ?
• Makes it easy to manage the whole API lifecycle from design to
sharing.
• Concise - you only write what you need to define.
• Reusable.
• Machine readable API design that is actually human friendly.
API Schema
Root
• Some basic information about the API. i.e. title, baseUri, version etc.
Resources
• Decides how API can be used by consumers.
Methods
• To define what consumers can do with the resources.
URI Parameters
• To have dynamic resources, to act upon the more granular objects of
the resources.
Query Parameters
• To be passed to methods, to extend the functionality of the API.
Responses
• HTTP status codes, may include descriptions, examples or schemas
Root
• Contains Some basic information about the API. i.e. title, baseUri,
version etc.
• Everything entered in at the root (or top) of the spec applies to the rest
of the API.
• Chosen baseURI will be used with every call made, hence make sure to
keep it clean and concise.
Example :
• #%RAML 0.8
• title: Employee Details Management
• version: v1
• baseUri:
https://mocksvc.mulesoft.com/mocks/c2a7ecf4-edd3-
4023-8373-c3a2cf325dda/api/{version}
Resources
• Decides how API can be used by consumers.
• Resources always begin with a slash ( / ) in RAML.
• Any methods and parameters nested under these top level resources
belong to and act upon that resource.
• Nesting of resources is also possible.
Example :
• /employees:
• /department:
• /region:
Methods
• To define what consumers can do with the resources.
• Most common HTTP methods :
• get : Retrieve the information defined in the request URI.
• put : Replace the addressed collection. At the object-level, create or update
it.
• post : Create a new entry in the collection. This method is generally not
used at the object-level.
• delete : Delete the information defined in the request URI.
• Each HTTP method can only be used once per resource.
• Lower case must be used for methods in RAML API definition.
Example :
• /employees:
• get:
• post:
• put:
delete:
URI Parameters
• To have dynamic resources, to act upon the more granular objects of
the resources.
• Used for nesting of resources.
• A URI parameter is denoted by surrounding curly brackets in RAML.
Example :
• /employees:
• /{employeeName}:
• With above, to make a request to this nested resource, the URI for the
employee, ‘Thomas Anderson’ would look like
– http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson
Query Parameters
• To be passed to methods, to extend the functionality of the API.
• To make developers to be able to perform more powerful actions, like
filtering a collection based on passed parameters.
• Query parameters may also be something that the server requires to
process the API consumer's request, like an access token.
Example :
• / employees :
• /{employeeName}
• get:
• queryParameters:
• employeeId :
• put:
• queryParameters:
• access_token:
Continue…
• Each query parameter may have any number of optional attributes to
further define it.
• Example :
• / employees :
• /{employeeName}
• get:
• queryParameters:
• employeeId :
• displayName: Employee Id
• type: string
• description: Id of an employee
• example: E001
• required: false
Responses
• A map of one or more HTTP status codes.
• Each response may include descriptions, examples or schemas
• Note the pipe ( | ) after ‘example’ keyword, it’s to indicate what follows
is a string, if not put, it’ll give an error saying, ‘example must be a
string’.
Example :
• / employees :
• /{employeeName}:
• get:
• description: Retrieves details of a specific employee
• responses:
• 200:
• body:
• application/json:
• example: |
• {
• …<sample data>
• },
• "success": true,
• "status": 200
• }
Example
Mule soft RAML API Designing
• The main flow for a RAML-based API manages these functions:
• Exposes the API using HTTP or Jetty.
• Routes requests between the interface and the backend flows based on
the HTTP request.
• References exception strategies that produce HTTP-status-code responses.
Main Flow
Backend Flows
• APIkit generates a backend flow for each resource-action pairing in a
RAML. APIkit for SOAP generates a backend flow for each operation in a
WSDL. For example, the RAML interface receives the GET request for sales
of T-shirts. The backend flow accesses a database to look up sales data
and responds to the request.
Flights API
API
United
American
Delta
Front-end
UI
Mule ESB
Connection Details
United Airlines: RESTful web service
• URL: http://mu.mulesoft-training.com/essentials/united/flights
Delta Airlines: web service• URL:
• URL: http://mu.mulesoft-training.com/essentials/delta
American Airlines: MySQL database
• Server: mudb.mulesoft-training.com
• Port: 3306
• User: mule
• Password: mule
• Database: training
• American table: flights

More Related Content

PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
PPTX
Design API using RAML - basics
PPTX
Rest and Sling Resolution
PPTX
Slim Framework
PPTX
Searching in AtoM
PPTX
REST-API's for architects and managers
PPT
What Is Hobo ?
PPTX
REST-API introduction for developers
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Design API using RAML - basics
Rest and Sling Resolution
Slim Framework
Searching in AtoM
REST-API's for architects and managers
What Is Hobo ?
REST-API introduction for developers

What's hot (18)

ODP
Creating APIs over RDF
PPTX
Apache solr
PPTX
Apex code (Salesforce)
PPTX
CakeFest 2013 - A-Z REST APIs
PDF
Ember.js Self Defining Apps
KEY
CakePHP REST Plugin
PDF
RESTful HATEOAS standards using Java based Katharsis
PDF
Making the Most of Modern PHP in Drupal 7
PPTX
Intro to php
PDF
Request-Response Cycle of Ruby on Rails App
PPTX
Skillwise - Advanced web application development
PPTX
OData RESTful implementation
PPT
Working with solr.pptx
PPTX
ODP
RESTful Web Services with JAX-RS
PPTX
Insight into java 1.8, OOP VS FP
PPTX
12 Introduction to Rails
PPT
JSP Part 2
Creating APIs over RDF
Apache solr
Apex code (Salesforce)
CakeFest 2013 - A-Z REST APIs
Ember.js Self Defining Apps
CakePHP REST Plugin
RESTful HATEOAS standards using Java based Katharsis
Making the Most of Modern PHP in Drupal 7
Intro to php
Request-Response Cycle of Ruby on Rails App
Skillwise - Advanced web application development
OData RESTful implementation
Working with solr.pptx
RESTful Web Services with JAX-RS
Insight into java 1.8, OOP VS FP
12 Introduction to Rails
JSP Part 2
Ad

Similar to Mule soft RAML API Designing (20)

PDF
Api security-testing
PPTX
Rest APIs Training
PPTX
Pragmatic REST APIs
PDF
(ATS6-PLAT04) Query service
PPTX
API Docs with OpenAPI 3.0
PDF
Web Services Tutorial
PDF
REST API Recommendations
PDF
Web Services PHP Tutorial
PPTX
Rest API Testing
PDF
restapitest-anil-200517181251.pdf
PPTX
Basic auth implementation using raml in mule
PPTX
Ei cakephp
PPTX
Cakeph pppt
PDF
Web services tutorial
PDF
The never-ending REST API design debate
PPTX
RESTful Services
PDF
Api design and development
PDF
Solr Recipes Workshop
PDF
Best Practices in Web Service Design
PPTX
API Testing Using REST Assured with TestNG
Api security-testing
Rest APIs Training
Pragmatic REST APIs
(ATS6-PLAT04) Query service
API Docs with OpenAPI 3.0
Web Services Tutorial
REST API Recommendations
Web Services PHP Tutorial
Rest API Testing
restapitest-anil-200517181251.pdf
Basic auth implementation using raml in mule
Ei cakephp
Cakeph pppt
Web services tutorial
The never-ending REST API design debate
RESTful Services
Api design and development
Solr Recipes Workshop
Best Practices in Web Service Design
API Testing Using REST Assured with TestNG
Ad

Recently uploaded (20)

PDF
composite construction of structures.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
OOP with Java - Java Introduction (Basics)
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
composite construction of structures.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
OOP with Java - Java Introduction (Basics)
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
CH1 Production IntroductoryConcepts.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
R24 SURVEYING LAB MANUAL for civil enggi
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf

Mule soft RAML API Designing

  • 1. API
  • 2. RAML API Designing Basics • Introduction • RAML API Schema • Root • Resources • Methods • URI Parameters • Query Parameters • Responses
  • 3. Introduction What is RAML ? • RAML : RESTful API Modeling Language. • Non-proprietary, vendor-neutral open spec. • Aims to help current API ecosystem and solve immediate problems, and then gently encourage ever-better API patterns. Why RAML ? • Makes it easy to manage the whole API lifecycle from design to sharing. • Concise - you only write what you need to define. • Reusable. • Machine readable API design that is actually human friendly.
  • 4. API Schema Root • Some basic information about the API. i.e. title, baseUri, version etc. Resources • Decides how API can be used by consumers. Methods • To define what consumers can do with the resources. URI Parameters • To have dynamic resources, to act upon the more granular objects of the resources. Query Parameters • To be passed to methods, to extend the functionality of the API. Responses • HTTP status codes, may include descriptions, examples or schemas
  • 5. Root • Contains Some basic information about the API. i.e. title, baseUri, version etc. • Everything entered in at the root (or top) of the spec applies to the rest of the API. • Chosen baseURI will be used with every call made, hence make sure to keep it clean and concise. Example : • #%RAML 0.8 • title: Employee Details Management • version: v1 • baseUri: https://mocksvc.mulesoft.com/mocks/c2a7ecf4-edd3- 4023-8373-c3a2cf325dda/api/{version}
  • 6. Resources • Decides how API can be used by consumers. • Resources always begin with a slash ( / ) in RAML. • Any methods and parameters nested under these top level resources belong to and act upon that resource. • Nesting of resources is also possible. Example : • /employees: • /department: • /region:
  • 7. Methods • To define what consumers can do with the resources. • Most common HTTP methods : • get : Retrieve the information defined in the request URI. • put : Replace the addressed collection. At the object-level, create or update it. • post : Create a new entry in the collection. This method is generally not used at the object-level. • delete : Delete the information defined in the request URI. • Each HTTP method can only be used once per resource. • Lower case must be used for methods in RAML API definition. Example : • /employees: • get: • post: • put: delete:
  • 8. URI Parameters • To have dynamic resources, to act upon the more granular objects of the resources. • Used for nesting of resources. • A URI parameter is denoted by surrounding curly brackets in RAML. Example : • /employees: • /{employeeName}: • With above, to make a request to this nested resource, the URI for the employee, ‘Thomas Anderson’ would look like – http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson
  • 9. Query Parameters • To be passed to methods, to extend the functionality of the API. • To make developers to be able to perform more powerful actions, like filtering a collection based on passed parameters. • Query parameters may also be something that the server requires to process the API consumer's request, like an access token. Example : • / employees : • /{employeeName} • get: • queryParameters: • employeeId : • put: • queryParameters: • access_token:
  • 10. Continue… • Each query parameter may have any number of optional attributes to further define it. • Example : • / employees : • /{employeeName} • get: • queryParameters: • employeeId : • displayName: Employee Id • type: string • description: Id of an employee • example: E001 • required: false
  • 11. Responses • A map of one or more HTTP status codes. • Each response may include descriptions, examples or schemas • Note the pipe ( | ) after ‘example’ keyword, it’s to indicate what follows is a string, if not put, it’ll give an error saying, ‘example must be a string’. Example : • / employees : • /{employeeName}: • get: • description: Retrieves details of a specific employee • responses: • 200: • body: • application/json: • example: | • { • …<sample data> • }, • "success": true, • "status": 200 • }
  • 14. • The main flow for a RAML-based API manages these functions: • Exposes the API using HTTP or Jetty. • Routes requests between the interface and the backend flows based on the HTTP request. • References exception strategies that produce HTTP-status-code responses. Main Flow
  • 15. Backend Flows • APIkit generates a backend flow for each resource-action pairing in a RAML. APIkit for SOAP generates a backend flow for each operation in a WSDL. For example, the RAML interface receives the GET request for sales of T-shirts. The backend flow accesses a database to look up sales data and responds to the request.
  • 17. Connection Details United Airlines: RESTful web service • URL: http://mu.mulesoft-training.com/essentials/united/flights Delta Airlines: web service• URL: • URL: http://mu.mulesoft-training.com/essentials/delta American Airlines: MySQL database • Server: mudb.mulesoft-training.com • Port: 3306 • User: mule • Password: mule • Database: training • American table: flights

Editor's Notes

  • #11: /books: /{bookTitle} get: queryParameters: author: displayName: Author type: string description: An author's full name example: Mary Roach required: false publicationYear: displayName: Pub Year type: number description: The year released for the first time in the US example: 1984 required: false rating: displayName: Rating type: number description: Average rating (1-5) submitted by users example: 3.14 required: false isbn: displayName: ISBN type: string minLength: 10 example: 0321736079? put: queryParameters: access_token: displayName: Access Token type: string description: Token giving you permission to make call required: true
  • #13: /books: /{bookTitle}: get: description: Retrieve a specific book title responses: 200: body: application/json: example: | { "data": { "id": "SbBGk", "title": "Stiff: The Curious Lives of Human Cadavers", "description": null, "datetime": 1341533193, "genre": "science", "author": "Mary Roach", "link": "http://e-bookmobile.com/books/Stiff", }, "success": true, "status": 200 }