SlideShare a Scribd company logo
1 of 19
API
Masters Academy, 2018
Application programing interface
REST (Representational State Transfer)
REST is a software architectural style that
defines a set of constraints to be used for
creating web services.
● Client–server architecture
● Statelessness
● Cacheability
● Layered system
● Uniform interface
○ Resource identification in requests
○ Resource manipulation through
representations
○ Self-descriptive messages
Naming convention
1. Keep your URL simple and intuitive.
2. Keep Verbs out of your base URLs.
3. Use HTTP verbs like GET, POST, (UPDATE, DELETE) to work on the
collections.
4. Plural names are better than singular names.
5. Some companies use singular but we use the plural.
6. Use concrete names then using short names.
GOOD
BAD
Error Handling and status codes
Use HTTP status codes. For example:
● 200 Ok (All went well)
● 400 bad requests (Some required PARAM is missing)
● 401 – Unauthorized (User, not login in. Consumer (Web app, mobile app)
of this API should redirect to Login page.)
● 403 Forbidden/ Access denied (logged user does not have access to this
resource)
● 500 Internal server error (something went wrong on server)
Versioning
Versioning is one of the most important considerations when designing your Web
API.
Never release an API without using version numbers.
Use /version/resource. Examples:
● /v1/projects
● /v1/projects/:id
● /v2/user/:id/projects
Pagination and Partial request
1. /v1/projects?limit=25&offset=50
Limit: number of projects
Offset: Skip these records
2. Use partial response syntax.
/v1/projects/?fields=name,id,stage
JSON Web Tokens
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting
information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be
signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA.
When should you use JSON Web Tokens?
Here are some scenarios where JSON Web Tokens are useful:
● Authorization: This is the most common scenario for using JWT. Once the user is logged in, each subsequent request will
include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On
is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different
domains.
● Information Exchange: JSON Web Tokens are a good way of securely transmitting information between parties. Because
JWTs can be signed—for example, using public/private key pairs—you can be sure the senders are who they say they are.
Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn't been
tampered with.
JWT structure (xxxxx.yyyyy.zzzzz)
● Header (xxxxx)
{
"alg": "HS256",
"typ": "JWT"
}
this JSON is Base64Url encoded to form the first part
of the JWT.
● Payload (yyyyy)
JSON object that cat contains any info.
{
"sub": "1234567890",
"name": "John Doe",
"admin": true
}
this JSON is Base64Url encoded to form the first part
of the JWT.
● Signature (zzzzz)
based on Header and Payload with using
selected algoritm
HMACSHA256(
base64UrlEncode(header) + "."
+ base64UrlEncode(payload),
secret)
Query languages or data query languages (DQLs) are computer languages
used to make queries in databases and information systems.
● Cypher is a query language for the Neo4j graph database;
● GraphQL is a data query language developed by Facebook as an alternate to REST and ad-hoc
webservice architectures.
● LINQ query-expressions is a way to query various data sources from .NET languages
● LDAP is an application protocol for querying and modifying directory services running over TCP/IP;
● ReQL is a query language used in RethinkDB;
● SQL is a well known query language and data manipulation language for relational databases;
● XQuery is a query language for XML data sources;
● XPath is a declarative language for navigating XML documents;
GraphQL
is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.[2] GraphQL
was developed internally by Facebook in 2012 before being publicly released in 2015.[3] On 7 November 2018, the GraphQL project
was moved from Facebook to the newly-established GraphQL foundation, hosted by the non-profit Linux Foundation.
Describe your data
type Project {
name: String
tagline: String
contributors: [User]
}
Ask for what you want
{
project(name:
"GraphQL") {
tagline
}
}
Get predictable results
{
"project": {
"tagline": "A query
language for APIs"
}
}
GraphQL ecosystem
Servers
● https://www.apollographql.com/
● GraphQL-JS
● GraphQL-Server
● Other
Clients
● Relay
● Apollo
SaaS
● Graphcool
● Scaphold
Resources
● GraphQL.org
● LearnGraphQL
● LearnApollo
● Apollo Blog
● GraphQL Weekly
● Hashbang Weekly
● Freecom
● Awesome GraphQL
REST vs GraphQL
REST
● Server driven selection
● Fetching multiple resources
● More in depth analytics
GraphQL
● Caching
● Architecture
● Exposed for arbitrary requests
● Rigidness of queries
● Non existent monitoring
Problems
API Documentation
Title
<Additional information about your API call. Try to use verbs
that match both request type (fetching vs modifying) and
plurality (one vs multiple).>
● URL
<The URL Structure (path only, no root url)>
● Method:
<The request type>
GET | POST | DELETE | PUT
● URL Params
<If URL params exist, specify them in accordance with
name mentioned in URL section. Separate into
optional and required. Document data constraints.>
● Required:
id=[integer]
● Optional:
photo_id=[alphanumeric]
● Data Params
<If making a post request, what should the body
payload look like? URL Params rules apply here too.>
● Success Response:
<What should the status code be on success and is
there any returned data? This is useful when people
need to to know what their callbacks should expect!>
Code: 200
Content: { id : 12 }
● Error Response:
<Most endpoints will have many ways they can fail.
From unauthorized access, to wrongful parameters
etc. All of those should be liste d here. It might seem
repetitive, but it helps prevent assumptions from being
made where they should be.>
Code: 401 UNAUTHORIZED
Content: { error : "Log in" }
● Sample Call:
<Just a sample call to your endpoint in a runnable
format ($.ajax call or a curl request) - this makes life
easier and more predictable.>
● Notes:
<This is where all uncertainties, commentary,
discussion etc. can go. I recommend timestamping
and identifying oneself when leaving comments
here.>
Show User
Returns json data about a single user.
● URL
/users/:id
● Method:
GET
● URL Params
● Required:
id=[integer]
● Data Params
None
● Success Response:
Code: 200
Content: { id : 12, name : "Michael Bloom" }
API Documentation example
● Error Response:
Code: 404 NOT FOUND
Content: { error : "User doesn't exist" }
OR
Code: 401 UNAUTHORIZED
Content: { error : "You are unauthorized to
make this request." }
● Sample Call:
$.ajax({
url: "/users/1",
dataType: "json",
type : "GET",
success : function(r) {
console.log(r);
}
});
RESTful API Description Languages
● OpenAPI Specification
○ URL: https://openapis.org/
○ developer: Open API Initiative (OAI), originally developed as "Swagger" specification by Wordnik, SmartBear Software
● RESTful API Modeling Language (RAML)
○ URL: http://raml.org/
○ developer: Mulesoft, http://www.mulesoft.com/
● API Blueprint
○ URL: https://apiblueprint.org/
○ developer Apiary, https://apiary.io/company
● API Builder
○ URL: https://www.apibuilder.io/
○ developers: HBC, Flow Commerce
Full list

More Related Content

What's hot

What's hot (20)

What's an api
What's an apiWhat's an api
What's an api
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Api presentation
Api presentationApi presentation
Api presentation
 
Api types
Api typesApi types
Api types
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST API
 
Api Testing
Api TestingApi Testing
Api Testing
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
 
Api testing
Api testingApi testing
Api testing
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Swagger
SwaggerSwagger
Swagger
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
 
Postman.ppt
Postman.pptPostman.ppt
Postman.ppt
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
 
Test your microservices with REST-Assured
Test your microservices with REST-AssuredTest your microservices with REST-Assured
Test your microservices with REST-Assured
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 

Similar to API

World wide web architecture presentation
World wide web architecture presentationWorld wide web architecture presentation
World wide web architecture presentation
ImMe Khan
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
Chamnap Chhorn
 
Android App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web ServicesAndroid App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web Services
Anuchit Chalothorn
 

Similar to API (20)

Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
 
Microservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFMicroservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCF
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
A RESTful introduction
A RESTful introductionA RESTful introduction
A RESTful introduction
 
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptxGDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptx
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
World wide web architecture presentation
World wide web architecture presentationWorld wide web architecture presentation
World wide web architecture presentation
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually rest
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
Api 101
Api 101Api 101
Api 101
 
Android App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web ServicesAndroid App Development 06 : Network &amp; Web Services
Android App Development 06 : Network &amp; Web Services
 
WebServices Basic Introduction
WebServices Basic IntroductionWebServices Basic Introduction
WebServices Basic Introduction
 
Fyp saufi
Fyp saufiFyp saufi
Fyp saufi
 
Introductiontowebarchitecture 090922221506-phpapp01
Introductiontowebarchitecture 090922221506-phpapp01Introductiontowebarchitecture 090922221506-phpapp01
Introductiontowebarchitecture 090922221506-phpapp01
 
Introduction of WebServices
Introduction of WebServicesIntroduction of WebServices
Introduction of WebServices
 

More from Masters Academy

More from Masters Academy (20)

Ruby Exceptions
Ruby ExceptionsRuby Exceptions
Ruby Exceptions
 
Basic Net technologies
Basic Net technologiesBasic Net technologies
Basic Net technologies
 
Databases
DatabasesDatabases
Databases
 
Environment
EnvironmentEnvironment
Environment
 
Frontend
FrontendFrontend
Frontend
 
Development Methodologies
Development MethodologiesDevelopment Methodologies
Development Methodologies
 
Object-Oriented Programming
Object-Oriented ProgrammingObject-Oriented Programming
Object-Oriented Programming
 
Testing
TestingTesting
Testing
 
Processing
ProcessingProcessing
Processing
 
Serialization
SerializationSerialization
Serialization
 
Serverless
ServerlessServerless
Serverless
 
Data Types
Data TypesData Types
Data Types
 
How to be up todate
How to be up todateHow to be up todate
How to be up todate
 
Call stack, event loop and async programming
Call stack, event loop and async programmingCall stack, event loop and async programming
Call stack, event loop and async programming
 
Html, css, js
Html, css, jsHtml, css, js
Html, css, js
 
Server architecture
Server architectureServer architecture
Server architecture
 
Serialization
SerializationSerialization
Serialization
 
Data types
Data typesData types
Data types
 
Net Technologies
Net TechnologiesNet Technologies
Net Technologies
 
Net Technologies
Net TechnologiesNet Technologies
Net Technologies
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 

API

  • 3. REST (Representational State Transfer) REST is a software architectural style that defines a set of constraints to be used for creating web services. ● Client–server architecture ● Statelessness ● Cacheability ● Layered system ● Uniform interface ○ Resource identification in requests ○ Resource manipulation through representations ○ Self-descriptive messages
  • 4. Naming convention 1. Keep your URL simple and intuitive. 2. Keep Verbs out of your base URLs. 3. Use HTTP verbs like GET, POST, (UPDATE, DELETE) to work on the collections. 4. Plural names are better than singular names. 5. Some companies use singular but we use the plural. 6. Use concrete names then using short names.
  • 6. Error Handling and status codes Use HTTP status codes. For example: ● 200 Ok (All went well) ● 400 bad requests (Some required PARAM is missing) ● 401 – Unauthorized (User, not login in. Consumer (Web app, mobile app) of this API should redirect to Login page.) ● 403 Forbidden/ Access denied (logged user does not have access to this resource) ● 500 Internal server error (something went wrong on server)
  • 7. Versioning Versioning is one of the most important considerations when designing your Web API. Never release an API without using version numbers. Use /version/resource. Examples: ● /v1/projects ● /v1/projects/:id ● /v2/user/:id/projects
  • 8. Pagination and Partial request 1. /v1/projects?limit=25&offset=50 Limit: number of projects Offset: Skip these records 2. Use partial response syntax. /v1/projects/?fields=name,id,stage
  • 9. JSON Web Tokens JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA. When should you use JSON Web Tokens? Here are some scenarios where JSON Web Tokens are useful: ● Authorization: This is the most common scenario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains. ● Information Exchange: JSON Web Tokens are a good way of securely transmitting information between parties. Because JWTs can be signed—for example, using public/private key pairs—you can be sure the senders are who they say they are. Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn't been tampered with.
  • 10. JWT structure (xxxxx.yyyyy.zzzzz) ● Header (xxxxx) { "alg": "HS256", "typ": "JWT" } this JSON is Base64Url encoded to form the first part of the JWT. ● Payload (yyyyy) JSON object that cat contains any info. { "sub": "1234567890", "name": "John Doe", "admin": true } this JSON is Base64Url encoded to form the first part of the JWT. ● Signature (zzzzz) based on Header and Payload with using selected algoritm HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret)
  • 11. Query languages or data query languages (DQLs) are computer languages used to make queries in databases and information systems. ● Cypher is a query language for the Neo4j graph database; ● GraphQL is a data query language developed by Facebook as an alternate to REST and ad-hoc webservice architectures. ● LINQ query-expressions is a way to query various data sources from .NET languages ● LDAP is an application protocol for querying and modifying directory services running over TCP/IP; ● ReQL is a query language used in RethinkDB; ● SQL is a well known query language and data manipulation language for relational databases; ● XQuery is a query language for XML data sources; ● XPath is a declarative language for navigating XML documents;
  • 12. GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.[2] GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.[3] On 7 November 2018, the GraphQL project was moved from Facebook to the newly-established GraphQL foundation, hosted by the non-profit Linux Foundation. Describe your data type Project { name: String tagline: String contributors: [User] } Ask for what you want { project(name: "GraphQL") { tagline } } Get predictable results { "project": { "tagline": "A query language for APIs" } }
  • 13.
  • 14. GraphQL ecosystem Servers ● https://www.apollographql.com/ ● GraphQL-JS ● GraphQL-Server ● Other Clients ● Relay ● Apollo SaaS ● Graphcool ● Scaphold Resources ● GraphQL.org ● LearnGraphQL ● LearnApollo ● Apollo Blog ● GraphQL Weekly ● Hashbang Weekly ● Freecom ● Awesome GraphQL
  • 16. REST ● Server driven selection ● Fetching multiple resources ● More in depth analytics GraphQL ● Caching ● Architecture ● Exposed for arbitrary requests ● Rigidness of queries ● Non existent monitoring Problems
  • 17. API Documentation Title <Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).> ● URL <The URL Structure (path only, no root url)> ● Method: <The request type> GET | POST | DELETE | PUT ● URL Params <If URL params exist, specify them in accordance with name mentioned in URL section. Separate into optional and required. Document data constraints.> ● Required: id=[integer] ● Optional: photo_id=[alphanumeric] ● Data Params <If making a post request, what should the body payload look like? URL Params rules apply here too.> ● Success Response: <What should the status code be on success and is there any returned data? This is useful when people need to to know what their callbacks should expect!> Code: 200 Content: { id : 12 } ● Error Response: <Most endpoints will have many ways they can fail. From unauthorized access, to wrongful parameters etc. All of those should be liste d here. It might seem repetitive, but it helps prevent assumptions from being made where they should be.> Code: 401 UNAUTHORIZED Content: { error : "Log in" } ● Sample Call: <Just a sample call to your endpoint in a runnable format ($.ajax call or a curl request) - this makes life easier and more predictable.> ● Notes: <This is where all uncertainties, commentary, discussion etc. can go. I recommend timestamping and identifying oneself when leaving comments here.>
  • 18. Show User Returns json data about a single user. ● URL /users/:id ● Method: GET ● URL Params ● Required: id=[integer] ● Data Params None ● Success Response: Code: 200 Content: { id : 12, name : "Michael Bloom" } API Documentation example ● Error Response: Code: 404 NOT FOUND Content: { error : "User doesn't exist" } OR Code: 401 UNAUTHORIZED Content: { error : "You are unauthorized to make this request." } ● Sample Call: $.ajax({ url: "/users/1", dataType: "json", type : "GET", success : function(r) { console.log(r); } });
  • 19. RESTful API Description Languages ● OpenAPI Specification ○ URL: https://openapis.org/ ○ developer: Open API Initiative (OAI), originally developed as "Swagger" specification by Wordnik, SmartBear Software ● RESTful API Modeling Language (RAML) ○ URL: http://raml.org/ ○ developer: Mulesoft, http://www.mulesoft.com/ ● API Blueprint ○ URL: https://apiblueprint.org/ ○ developer Apiary, https://apiary.io/company ● API Builder ○ URL: https://www.apibuilder.io/ ○ developers: HBC, Flow Commerce Full list