Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,457 members, 7,808,631 topics. Date: Thursday, 25 April 2024 at 02:30 PM

What Is Api - Science/Technology - Nairaland

Nairaland Forum / Science/Technology / What Is Api (237 Views)

Mobile App And API Development / How To Fix Paypal API Error Code 10426? / API Kits For Identification And Confirmation Of Microorganisms (2) (3) (4)

(1) (Reply)

What Is Api by opemite: 9:35pm On Jul 19, 2021
What Is An API?
Wondering what an API is? API stands for Application Programming Interface. It is a piece of code that lets two programs talk to each other. A way to pass information and data between two programs. Directly. Don’t worry, they’re not as complicated as they sound. An API is quite simple to use. You’re really only sending a small piece of code to a server to get a response.

What’s the point of an API?
There are many reasons to use an API. But ultimately it’s to quickly send useful information between two programs. For example, imagine you’re developing a website. You want the website’s background to change based on the current weather. How do you do it? You could set up a camera to look out the window, add some complicated machine learning to figure out whether it’s raining or not, and then change the background based on the result. Alternatively, you could create a program that scraped your local news and grab the weather from the webpage.

Both of those options are rather inefficient. Instead, you can just go to OpenWeather and use their API to ask them what the weather is. All through one line of code. Much easier. This is a rather basic example. In the real world, you’re likely sending data from your application to a third party, they process it on their end, and then you retrieve the answer. But the principle is the same. APIs take a complicated task and turn it into just a few lines of code.

How do they work?
An API can only send and retrieve data or functions that have been programmed in. The creator of the API will show which commands you’ll need to send to retrieve or send data to them. Often, you’ll also need an authentication code. This is basically your login information and proves that the command you’re sending is coming from you. To interact with an API, it’s very similar to just typing in a web address. You’re just adding a little code to the URL, so it looks like this:
api.acme.com/?get=bunny_season=a[authcode]

Once you send that, you’ll get a response. The format for the data you get back will depend on the API, but is often something like XML or JSON. And exactly how you make this request inside your code will depend on the programming language you’re using.

What can an API do?
There are typically only four actions you can take:

Get. Ask for data from the server.
Post. Send data to the server and add it.
Put. Change data.
Delete. Deletes data.
Using a combination of these actions, you can do pretty much anything you like with an API. It all depends on what the developer has set the API up to do.

How might you use an API?
You might use an API in three different ways:

An internal system
Let’s imagine you’re a global cinema company. You have a website with a booking system and a lot of cinemas, each with their own screens and seats. How do you know how many seats are available?

You might have a giant database that syncs everything, but that’s quite impractical. Instead, you could have an API with each cinema. Your website then pings the cinema, checks how many seats are available (and which ones they are) for the movie and then it sends back the response. Your website can do all the heavy lifting of showing it to the user in a nice neat way. And because it’s a simple request, it doesn’t clog up the bandwidth for the cinema itself. That way, the user gets the same experience for every cinema. But also, you can easily just update the website if you have a design change.

Link with a partner
This time, let’s imagine we’re a data analytics company. You might have a tool that collects data from a museum. It takes data from the audio-tour device you give to people, records their path and then figures out what people enjoy. Great. But what if the museum wants to see that data in a better way? You might not have the skills in-house to create the visualization. Instead, you might partner up with another company and use their software. An API is great for this. You can plug your two pieces of software into each other and have them work as a single unit. It’s not public data, so they use an authentication code to prove they can use the data.

Open up to the public
Lastly, you might just want to make your data public. OpenWeather, for example, wants anybody to be able to use its data. An API lets you give this data to people, without them getting access to the raw database.

(1) (Reply)

Database Software / New Study Unveils Complexity And Vast Diversity Of Africa’s Genetic Variation / Scientists Identify Antibodies That Can Neutralize Omicron

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.