API stands for Application Programming Interface. It is a piece of software that can be used by another piece of software, to allow applications to talk to each other.
Web API in particular simply refers to an app that sends data to a client whenever a request comes in. Here, we have client and server talking to each other through the API.
In this part, we have created a simple Web API, using JSON data from a file.
To understand more about creating the web server, you may refer part 1.
To understand more about implementation of Routes in Node, you may refer part 2.
-
Clone or download the repository.
-
Once you've downloaded the repo, Open it in an editor of your choice.
-
Open the terminal and traverse to part_2 directory.
-
Now run command
node index.js
to start the server. -
Open your browser and go to
127.0.0.1:8000
to see your server running. -
Go to
127.0.0.1:8000/api
, to test the working of the API. Refer todev-data/apiData.json
to see the dummy JSON data that we have used.
To Learn more about how to build an API in Node.js, you may refer this article.