r/AskProgramming • • Mar 26 '20

APIs Explained ...

I dunno but I don't understand APIs fluently. Does anyone know of an informative article or perhaps a website or just personally explain to me frankly wtf APIs are an why we need them ...

Edit: Thanks everyone for your empathetic contributions. Guess what; I have a better understanding of APIs now than I did before.

53 Upvotes

60 comments sorted by

View all comments

128

u/Jrobah Mar 26 '20

API - Application Programming Interface. It is a way of allowing you to access the data from another application or a way of applications to communicate with each other.

Take the example of a restaurant, since it belongs to someone else and you are not allowed to go to the Kitchen therefore the menu is the API. Allows you to make an order for food. Food is like data which you request for. The order you make is called an API call. When you make an order, the waiter will give you a response eg the food is available or not. Same happens with APIs, when you make an api call, you will either get a successful response and get your data or get an error and no data.

Now you can refer to the more technical explanations given in the thread

13

u/cellwall-999 Mar 26 '20

Thanks Dude. This really makes sense.

Anyways, how about a rest/restful API or whatever ...? How is that different from an actual APIs?

12

u/frostbyte650 Mar 26 '20 edited Mar 26 '20

REST is the most popular way to design a web API

An API that follows the REST paradigm is considered “RESTful”

There are other ways to design a web API, such as SOAP, but unless you work with old web services, you’ll likely deal with REST

4

u/cellwall-999 Mar 26 '20

But, do APIs always need internet access to get data?

For example: I can view my account balance on my phone, send money and buy airtime from my account without having internet access or is these not an API at work?

Just curious...

3

u/frostbyte650 Mar 26 '20 edited Mar 26 '20

Yes web APIs basically are the internet so without a connection your device has no way of telling the API server you want to do something

Think about it like this:

A web API is a program running on a literal machine in a datacenter somewhere. Your internet connection connects your device to that machine.

If you want to get technical then you could actually launch a server on a computer on your home network & as long as you’re connected to the same network on your other device you could access that API even if you couldn’t access the World Wide Web. This is generally known as LAN

1

u/cellwall-999 Mar 26 '20

I do send money to anyone without have Internet access.

Maybe there is a protocol that allows you to connect to the database of your Bank account or wth really happens here?

I do view, purchase airtime and send money without internet access just using my phone.

I just use a private code that prompts me to enter my Pin and then booom...

8

u/frostbyte650 Mar 26 '20

You’re either connected to a VPN or the request is stored & sent when you do have internet access.

That or you’re confusing internet with WiFi & need to realize cellular data is essentially the same thing

-11

u/cellwall-999 Mar 26 '20

No, I do understand the internet and all the the WiFi shit.

The thing is; you can do all the stuff I said without a smartphone.

3

u/frostbyte650 Mar 26 '20 edited Mar 26 '20

I mean, it’s possible I guess that they’re doing it over phone like you call them and dial your pin in which case they’re still likely translating that to a digital message & sending it via internet to their API for you but that’s a really insecure way to do something as sensitive as sending money

2

u/nutrecht Mar 26 '20

What you do mean with sending money?

-2

u/cellwall-999 Mar 26 '20

Yes. To anyone (locally).

→ More replies (0)

1

u/Enzyesha Mar 26 '20

How exactly do you think that money is being transferred?

0

u/cellwall-999 Mar 26 '20

That is exactly what I want to know.

→ More replies (0)

2

u/YouDoNotKnowMeSir Mar 26 '20

API can be used in a lot of things. Web API will need internet access or network access depending on if you’re leaving your private network or not.

An example of an API that is used for software not web is android OS. Android OS has tons of system features and apps, they all talk to each other using an API. This is the glue for them, it’s what makes communication possible between their system and apps.