API, REST, and so on - mantoskez/mantas-wiki GitHub Wiki
API
An Application Programming Interface (API) is a tool set that programmers can use in helping them create software. A good API will have clear and concise commands that a programmer can use and reuse, so they don't have to build everything over again. (API) is a set of functions, procedures, methods or classes used by computer programs to request services from the operating system, software libraries or any other service providers running on the computer. A computer programmer uses the API to make application programs. An API works by communicating with and exchanging data with other systems, acting as a messenger between the user and the system to retrieve the necessary data the user is requesting from the system. API stands for application programmer interface, which is a fancy name for whatever a programmer uses to interact with a language or library. For example, Processing’s reference is an API: it’s the classes and functions we used to write Processing code. Similarly, the Java API is the list of classes and functions we use to write Java code. You can view JavaScript’s API on MDN. The point is that an API is a collection of things we can do when writing code. So when we say we’re creating a REST API, we just mean that we’re using REST ideas to create something that programmers can use to interact with our data. Main types of web APIs:
- Open APIs - available to the public; they can be accessed by any external users.
- Partner APIs - available to strategic business partners; they are exposed to a public API developer portal.
- Internal APIs - available to a company's internal development teams; they are exposed to a private API developer portal.
- Composite APIs - are a sequence of tasks bundled into a single API call. Thus, the nuts and bolts of the largest category of APIs are that they connect applications together, allowing them to communicate with one another. https://www.cleo.com/blog/knowledge-base-what-is-an-api
REST
REST stands for REpresentational State Transfer. REST is an architectural style, or design pattern, for APIs.
REST APIs
REST APIs, also known as RESTful APIs, stands for Representational State Transfer. REST APIs have grown in popularity of late, as a part of Web Services. REST APIs are designed for developers to perform requests and receive responses via HTTP functions. There are four different HTTP commands that REST is based on. These include GET, PUT, POST, and DELETE. When you pull up Instagram and search for the latest and greatest meme of the day, that app is using a REST API. To put it another way: a REST API is just a web app, very similar to all of the web apps we’ve already built. The only difference is that instead of showing a website for a GET request, it provides data. And instead of using HTML forms to create a POST request, it takes POST requests from other applications! (Of course, one of those applications could be another web app that gets user input using HTML forms!) https://eliya-b.medium.com/restful-api-explained-a87e46c65c3d
SOAP APIs
SOAP stands for Simple Object Access Protocol. While REST is an architectural style, SOAP is a protocol that is defined by a standard. SOAP is dependent on XML-based systems and programming, tending to have larger, more expensive data. SOAP APIs also provide a higher level of security. A common use case is an application interacting with a financial institution.
RPC APIs
RPC stands for Remote Procedure Call. RPC APIs were the earliest form of APIs, as they are designed to execute a block of code on a different server. When it is used over HTTP, it can become a Web API.
Client — the client is the person or software who uses the API. It can be a developer, for example you, as a developer, can use Twitter API to read and write data from Twitter, create a new tweet and do more actions in a program that you write. Your program will call Twitter’s API. The client can also be a web browser. When you go to Twitter website, your browser is the client who calls Twitter API and uses the returned data to render information on the screen.
Resource — a resource can be any object the API can provide information about. In Instagram’s API, for example, a resource can be a user, a photo, a hashtag. Each resource has a unique identifier. The identifier can be a name or a number.
CRUD
- CRUD stands for Create, Read, Update, Delete. Those are basic operations that our API must support for all or part of our resources. If we look at the SQL implementation of CRUD, we will see that we can achieve it by using:
- Create - INSERT
- Read - SELECT
- Update - UPDATE
- Delete - DELETE
We can also achieve that with our RESTful API with the corresponding HTTP verbs like so:
- Create - POST
- Read - GET
- Update - PUT
- Delete - DELETE