Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open API vs. REST API - difference

Tags:

rest

openapi

How is Open API different from a REST API exposed on Internet? When Open API is explained it explains about an API getting exposed in LAN against exposing it to public . So what exactly is the difference?

like image 811
Harish Narayanan Avatar asked Jan 06 '18 02:01

Harish Narayanan


People also ask

What is difference between OpenAPI and REST API?

SOAP APIs. The most common open API architectures fall into two categories: REST APIs and SOAP APIs. SOAP and REST offer different methods to invoke a web service. SOAP-based APIs typically use XML as a data exchange format, while RESTful APIs typically use JSON back and forth.

Is OpenAPI RESTful?

Introduction. The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

What is difference between REST API and Web API?

Web API can be hosted only on an Internet Information Service (IIS) or self that supports XML and JSON requests. In contrast, REST API can be hosted only on IIS that supports standardized XML requests.

What are the 4 types of API?

There are four principal types of API commonly used in web-based applications: public, partner, private and composite.


1 Answers

REST (REpresentational State Transfer) describes a way how a clients and servers interact with each other. REST communication typically bases on HTTP protocol (but that isn't a requirement) and requests are made to a resource URI, possibly containing additional request data, and replies can be anything: HTML, XML, JSON, CSV, plain-text or even raw binary data. It's not a concrete protocol but a way of communication a protocol can use, similar to SOAP or WSDL.

To access a REST service, the client needs to know the REST API that service if offering, so there must be documentation and you need to write code according to that documentation. With OpenAPI this step is automated. With OpenAPI, there exists a machine parse-able file that explains computers how a REST API works. It tells code what requests exists and what replies to expect. To quote from the OpenAPI description:

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for REST APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic.

https://github.com/OAI/OpenAPI-Specification

So if you have a OpenAPI implementation and an OpenAPI description file of a REST API, you can feed that description file to the OpenAPI implementation and this implementation now knows how to use the REST API, it can generate human readable documentation for you or it could even auto generate code to use the REST API in different languages.

One could compare that to XML and DTD. XML is like REST, just that XML describes data and not communication. But millions of different XML based data formats exist, to parse a XML file correctly, the code needs to know what tags exist, which tags may have which sub-tags, which data to expect as tag content (an int, a string, a UUID, etc.) and so on. All of this is defined by a DTD (Document Type Definition) which is comparable to an OpenAPI description file. Code that understands DTDs can be fed with a DTD and then parse XML data claiming to conform to that DTD and verify if that's actually true (does it only use allowed tags, is the tag interleaving valid, are the tag values correct, and so on).

E.g. here's the DTD for XHMTL:
https://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict

like image 76
Mecki Avatar answered Oct 29 '22 22:10

Mecki