How we build a API and how does API works?

Hello everyone, Please I need a full explained answer of this question I am on trouble about this question.

How we build a API ? For example I will take example of a hotel booking website.

Such site has there own website from where users can login/register and get collect datas and they have there mobile app also which does the same work.

How did they build the application and website that has the same data showing everytime? Like I heard they have api that works and gets data for both application and website but how that works and how we do that?

Like how does API works and how we build API please someone explain me briefly about this. I am not understanding the way it works!

API means: application programming interface. But what does that mean?

lets break it down. We have API, which implies that we have different kind of interfaces. There is CLI (command line interface) and GUI (graphical user interface). Anything you do at your phone or computer uses a GUI. The browser you currently use to read my answer is a GUI application.

Lets take facebook and/or twitter as example. These companies sit on a massive amount of data (lets call them posts). Wouldn’t it be nice that if we are building our website, we could display posts/tweets on our website? Which is why FB and twitter made API’s, so we can retrieve data from there server, to display on our website :slight_smile:

When building our own website, we don’t have to build an API. Back-end programming languages (golang, java, C#, php, ruby, python) are capable of returning views with data which can be rendered in the browser

there are even tools to wrap the websites and publish them as app in the app store.

So we still haven’t build an API. We would start needing an API when our website would be a SPA (with reactJS or vueJS for example), or we build native apps (swift for IOS and Java or kotin for android)

If we start using an API, our back-end is only sending out data, which then needs to be handled in the front-end (by your SPA or native apps). This process of development is longer and most costly.


Thank you very much for your reply stetim,

I understand the process but my question was, how we build an API?

I have one concept about API please let me know if my concept is correct or not. If not correct then please correct me.

For example: if the website is built with MySQL database, PHP - for backend and JS, HTML, CSS for frontend. If say this site holds the values like let’s say a file-sharing website. If users after logged in uploads files then it shows the details of that particular user like the number of files users uploaded, no. of times the user’s file was downloaded, etc.

So if I want to convert this filesharing website to my mobile app which I will build with nodeJs then how will I get the data of my website?

Will I have to use the same database of MySQL and is it possible to use the same database for application and for a website?

Please explain to me the correct way/things how this works? Please this detail is very helpful for me so please explain to me each and every step of how we do it and how it works on the backend.

I am seeking your help.

Thank you very much

Php is perfectly capable of returning views, so you don’t have to build an API for your website. So you can use views for website, and API for your mobile app which utilize the same database.

if you also want to use the API for your website, you will need to also build your own front-end interface with js (framework might help here). But that is even more work and time consuming.

How does nodeJS work for apps? that is new for me. I though nodeJS was back-end also? With something like this: Wouldn’t using react native or electron for your mobile apps make more sense?

Although I understand the difference layers, I have worked to little with nodeJS to say something sensible about it. Be careful to pick the right tools and frameworks.

Ignoring nodeJS for a second, this is where the API comes in. Your app can fetch data from the API and display the fetched data in the front-end (this can be either web (SPA or using Javascript) or a mobile app).

If you understand what an API is, you understand that in a mobile app or single page application (SPA), we can fetch the data, and then in de the front-end/app, display this data.

Yes, this is absolutely possible. Otherwise, having an app and website would be a massive headache


Hi @arjunspark,

There are also lots of good resources out there for API design and best practices. Here are just a couple I found quickly:

APIs are definitely not necessary for small applications early in your learning but they are a key component of modern system design. They will definitely be a part of some system you integrate with or work on directly in the future.

1 Like