%% date:: [[2021-09-17]], [[2021-03-30]], [[2023-07-13]] parent:: %% # [[API]] API stands for **A**pplication **P**rogramming **I**nterface. In simple terms, an API is a set of rules for **how** to communicate with an application. These rules are necessary so that the application server can understand requests and process them accordingly.‌ When a user accesses a web app through a browser, his or her clicks on the page and other interactions actually send requests to the server. APIs allow you to bypass those clicks in the UI and just get the information directly by sending requests.‌ ## Types of API design models API is a standard for communication, but it is not a universal one. A major distinction in how APIs are designed is whether they are entity-oriented or procedure-oriented. ### Entity-oriented These frameworks lay out rules for how to retrieve an entity or resource on the server. They often use [[HTTP]] as a [[Transport Protocol]], although some can be used with other protocols. Regardless, they are different from procedure-oriented API models in that what is being requested is an asset (or data entity) on a server, and the actual functions that serve that asset are abstracted. - [[Simple Object Access Protocol]] (SOAP) - [[REST]] - [[GraphQL]] ### Procedure-oriented These frameworks allow applications to make [[Remote Procedure Call]]s: unlike entity-oriented API frameworks, procedure-oriented ones call functions on remote servers, while abstracting the actual assets or resources that those functions may call in turn. - [[OpenAPI]] can be thought of as an implementation of RPC that includes custom mappings of procedures to [[HTTP]]. [^google] - [[gRPC]] is an implementation of RPC that uses HTTP 2.0, and so is procedure-oriented but with an entity-oriented twist. - [[JSON-RPC]] - [[XML-RPC]] - [[CoAP]] ## How to [[Load Testing|load test]] APIs APIs can also present a more efficient way to load test your web application. Load testing is determining the traffic that you can expect from production and applying it systematically to your application servers in order to determine how the application behaves. It's a way to check whether your application is robust enough to handle the traffic you want it to handle. Load testing is one type of performance testing, which is sometimes referred to as non-functional testing. In API load testing, instead of your browser sending messages like `GET https://pokeapi.co/api/v2/pokemon/vaporeon`, you can use testing tools that will do that for you at scale. There are commercial and open source tools that you can use to create test scripts that you can use to tell those tools which messages to send and when. With API load testing, you can simulate multiple concurrent users sending requests to your server at the same time. ## See also - [[API Load Testing - A Beginner's Guide]] [^google]: Nally, M. (2020). *gRPC vs REST: Understanding gRPC, OpenAPI and REST and when to use them in API design.* Retrieved on July 13th, 2023 from https://cloud.google.com/blog/products/api-management/understanding-grpc-openapi-and-rest-and-when-to-use-them