EXAMPLE API
Example 1: what is an api
An application program interface (API) is a set of routines, protocols, and
tools for building software applications.
Basically, an API specifies how software components should interact.
Additionally, APIs are used when programming graphical user interface (GUI)
components.
A good API makes it easier to develop a program by providing all the
building blocks. A programmer then puts the blocks together.
Example 2: json placeholder
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => console.log(json))
Example 3: dummy api json
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://reqres.in/api/products/3", true);
xhr.onload = function(){
console.log(xhr.responseText);
};
xhr.send();
Example 4: advantages of api
1-We can start testing process
EARLY and the more bugs we
catch in API level testing,
the less bugs we will see on UI.
API level of application is
developed before the UI part.
2- API tests enable highly
integrable tests, which is
particularly useful if you
want to perform functional
GUI tests after API testing.
3-In API testing,
data is exchanged
using XML or JSON.
4- Time Effective:
API testing usually is less time consuming
than functional GUI testing.
Example 5: dummy api
React Fakers is a collection of dummy data from the most popular dummy data
providers such as Json Place Holder, Faker, Pokemon, etc,
for application development testing.
npm i react-fakers | yarn add react-fakers
Example 6: api documentation
Yes we use swagger for our API documentation and this is
where the description and guidelines of API endpoints are.