The difference between an API and a REST API

605 views

The difference between an API and a REST API

In: 198

15 Answers

Anonymous 0 Comments

REST is standardized architecture style for web based API.

API can be web based, but can also be local based, as example, windows api which allows you to execute actions on windows.

Anonymous 0 Comments

An API is just a formal, well-defined interface for programs to interact with each other. These interacting programs can be running on the same machine, or they can be communicating over a network. Doesn’t matter. The API just makes it possible to pass data back and forth in a structured manner.

A REST API is a certain type of API. It defines a set of standard rules as to how the computer hosting the API is supposed to behave, how it’s supposed to handle requests made to it, how you’re supposed to interact with it, how you’re supposed to access its data. The implementation details, that is how the API works under the hood, don’t matter. What a REST API is all about is how requests are responded to. It’s primarily used on servers where clients must be able to access, create or manipulate data.

Anonymous 0 Comments

An API is an “application programming interface” between two computer programs. It’s a rule that says “if you ask me a question like this, then I will do this thing and give you an answer like this”. If computer A agrees to this contract, then it is a service that “hosts the API” or “exposes the API”.

A REST API is a “Representational State Transfer API”. People realized quickly that a lot of APIs involve changing the “state” of data by the service hosting the API. Think creating an account, check the balance, updating a password, deleting an account. It became so common that Roy Fielding published a paper describing a new “style” of APIs called REST: https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2

Today, REST APIs typically expose four “methods” to operate on each “entity” of data:

* GET – retrieve the entity
* POST – create a new entity
* PUT – update the entity
* DELETE – remove the entity

Any service that exposes these methods and implements them so that they do those operations is considered to be hosting a REST API.

Anonymous 0 Comments

API = A wall socket
RESTful API = Use a 3 pronged power plug, with the right prong being bigger than the left prong. None of that 2 pronged SOAP trash from the oughts.

Anonymous 0 Comments

Technically correct answer: a REST api is stateless, http-based and **returns hypertext**

Real-life answer: a REST api is http-based, probably stateless, and almost certainly **doesn’t** return hypertext

More info here: [https://htmx.org/essays/how-did-rest-come-to-mean-the-opposite-of-rest/](https://htmx.org/essays/how-did-rest-come-to-mean-the-opposite-of-rest/)

Anonymous 0 Comments

I think the thing people missing in their explanations of what REST is, is that it’s stateless. Other APIs might require multiple executions to accomplish a single-atomic task. With REST, the idea is that the entire GET/PUT/POST/DELETE call contains everything needed to complete the transaction. Are there APIs that are labeled REST that break this convention, yes…. but this is really the main idea of REST when the paper on it was first published.

Anonymous 0 Comments

API = All the commands a computer system can do. Open and close files, read and write data, etc.

REST API = The same commands, except over the Web.

Anonymous 0 Comments

You can think of an API as a sort of plug. Like an outlet on your wall. What matters is that the wires connect. You can arrange the plug in 400 different ways to make the wires connect. (In the same way that plugs in Europe are different from those in the United States). REST is just one way of arranging the wires so that people can make more standardized ways of connecting the wires.

REST isn’t the only organized way of doing this. There used to be others but most people gravitated towards REST which is why it is the most common these days.

Anonymous 0 Comments

It’s like asking the difference between a furniture and a chair.

The API is a defined way a program can talk to another program, computer or hardware.

The REST API is a specific type of API, it defines a specific and flexible way that a server can accept requests and how it should return them.

Anonymous 0 Comments

API = how programs talk to each other

REST API = how programs talk to each other, with a buzzword in front. This particular API is almost always over http for boilerplate web apps and suggests that every ‘thing’ have 4 associated http functions for creating, reading, updating and deleting the ‘thing’.

In reality, bits dont get ‘deleted’, and in most circumstances an update should look the same as a write. A REST API does however mean a read/write is likely coded for whatever ‘thing’ the programmer wanted to send, and also likely means it can be read from the browser.