How does an API work?

920 views

Twitter recently announced they will no longer support free access to the Twitter API. Everyone seems up in arms about it and I can’t figure out what an API even is. What would doing something like this actually affect?

I’ve tried looking up what an API is, but I can’t really wrap my head around it.

Edit: I’ve had so many responses to read through and there’s been a ton of helpful explanations! Much appreciated everyone 🙂 thanks for keeping this doofus in the know

In: 419

41 Answers

Anonymous 0 Comments

Let’s simplify things and say we can interact with Twitter in two ways: reading posts and making posts. You can go to Twitter (either the website or the app) and do either of these things.

However, have you ever seen Twitter posts shown on other websites or apps? Have you ever posted on Twitter from within another app? Those websites or apps talk to Twitter on your behalf, but they aren’t Twitter themselves.

When third parties communicate with your target on your behalf like this, they use what’s called an API, which is just a common language on how to do the things you want (read posts or make posts in this case).

If Twitter makes its API paid, every website or app that wants to show you posts or make posts on your behalf would have to pay that fee.

Anonymous 0 Comments

Think of API as a fast food drive trough, the developer (you) drive to the window and order some information and the API serve this information back to you

This is usefull for programs to get data and/or integrate a system into theirs

Information this context means like the latest 500 000 tweets and data connected to them or Ben Bigdongs tweets between 2015-2016 and the first 100 comments on it (these are made up as I havent used the twitter api, but for explanation it suffice)

Anonymous 0 Comments

Imagine you come up to a vending machine.

You can do a whole lot with this vending machine. You can:

– Look at the options
– Put a coin in
– Press a button

And the vending machine can respond with:

– Tell you the options
– Tell you how much money you have in
– Dispense a soda if you pressed a button and have enough money

What you **can’t** do is open the vending machine (unless you “logged in” with a vending machine key of course,) or grab the soda from inside, or unplug it. In fact, you don’t even want to. You don’t want the vending machine to give you a run down of every step in the inside mechanical process to give you your soda or how it calculates how much money you have.

Now this is all you need from a vending machine to get your soda.

You can even make a little vending machine grabbing robot which wheels over and puts in the money and gets the soda for you. The robot doesn’t care what’s going on inside the vending machine either.

So in this case, the API is the front of the soda machine – what you can (and can’t) do. Your Apps are like the robot, which wouldn’t be possible if the soda machine was just a blank wall.

*What Twitter wants to do is charge you for even looking at their soda machine.*

So let’s put this into practice, because it’s much worse than it sounds. Let’s say the soda machine now has a guy, let’s call them Big Bird (this is ELI5 after-all,) who’s come on some hard times so was hired by the soda machine company to stand in front of the soda machine, completely blocking it, until you give them a quarter.

If you try to look at the vending machine, they smack you. Quarter first.

Now this soda machine is in a busy spot, the train station near the offices or something, and tons of people come to this exact vending machine to get their soda. It’s part of their routine, right?

Some people will arrive, quickly realize there’s a fee, and then adjust their routine and pay the 25 cents.

But MOST people will look at Big Bird and say… Nope. Not interested in soda anymore. When someone asks them what soda they got they’ll respond with “None.”

Now the real issue is let’s say there’s an elderly person who’s been doing this for decades and they don’t get the new system. They’re going to try to look at the vending machine, get smacked, and break a few bones. More than a few of these will be important people, like, for example, the train station manager, or a news reporter, who because they tried to get a soda are now broken.

As for your robot? They’ll be smacked so fast they’ll be on the curb. And so will everyone else’s robot.

All over the train station there’ll be people and robots on the floor, maybe in a pile of yellow feathers, because the vending machine company wants to eek out an extra 25 cents.

And that’s why it’s a big deal – it’s not only the extra 25 cents, which is greedy in itself and goes against the idea of even making an API, but it’s that thousands of Apps (many of them without the maintenance team or resources for this) will break.

Anonymous 0 Comments

Addresses and stamps are like the API we use to communicate with the postal service and mail carriers.

They are rules and structure about how information is communicated between systems.

In the case of a website like Twitter, it’s not just where data is sent, but the form it takes, so an app that talks to Twitter and twitter’s servers can understand each other.

Anonymous 0 Comments

Imagine you have a TV, Cable Box, Apple TV or Andriod TV, and your stereo system DVD player.

As far as your are concerned they all work together. But they all have their own remote controls.

You want to customize how you use your home system so you buy a programmable universal remote control that that will send messages to all devices and get data from them.

You are going down to a single remote, but you can customize it to however you want it to work and behave with your TV, DVD player and Cable box and internet devices. And it will take some work to program it to you liking. But once its done you will have an experience that is best for you.

How that Universal programable remote talks to your TV, Stereo, Apple TV and Cable box is very similar to the concept of API’s.

Twitter has said that unless you want to pay us, you need to use our tools with the tools we provide you.

Anonymous 0 Comments

If you imagine a computer system like a giant house. There may be info or things you want from inside that house but you aren’t allowed to just go in and take it.

An API is basically a butler. You can walk up to the front door and ask the butler to do something specific for you, there is a list of things he will do and you have that list. The butler will do all the work in the house to find and get the stuff you need and come back to the door to give it to you.

Anonymous 0 Comments

TL;DR it’s a standardised way of talking to the machine – a list of commands you can give and what sort of answers you’ll get back.

It’s just a description of how to talk to something and what happens when you do.

So for example if you wanted to write a program that gets all of Elon Musk’s tweets, there needs to be some way to ask twitter’s server for that list, and also some description of the format that list will be in when it comes back so that you can actually read it.

This means that as long as the API stays the same, Twitter could change all their systems around behind the scenes and your program will still work – or you could change your whole program around and Twitter won’t care because you’re both still asking the same question and getting the same answer.

Anonymous 0 Comments

API or Application Programming Interface is kind of like a digital menu over the types of data a company or service offers. Basically when you are using the reddit app on your phone or the twitter app they are accessing the api to get the feed from the reddit server.

It sounds more complicated than it actually is. One example is if you want to get the comments for this post. Then you ask the reddit api to bring you the comments for /r/explainlikeimfive/comments/10rnu6s/eli5_how_does_an_api_work/ and the api will return a list of data which each consists of a comment, a parent comment, a username, number of up/downvotes, awards and the time it was last posted and the time it was last edited as a little form. And repeats this form for each comment of this thread.

Anonymous 0 Comments

As humans we’re very good at understanding data visually. That’s why we prefer to look at graphs rather than big tables of data. ( Big shout out to r/dataisbeautiful 🙂 )

For that reason we mostly prefer to use a GUI (Graphical User Interface – like a web site for example) to get information. Computers, on the other hand, find it way easier to work with structured data (XML, JSON, etc.. take your pick).

An API (Application Programming Interface) is just a way of bypassing all the messy visual and layout stuff that computers hate and just feed it the raw data it loves.

So why bother? Well if you need an application to consume some data from another application, it’s more predictable and easier for the code get it from an API and access only the raw data, without all the peripheral visual stuff it doesn’t have any use for. It also means you can redesign your GUI (aka website) to the latest in cool, funky design language without changing anything on the API, and so not risk breaking other apps that reply on that data.

Your GUI and your API could very well send exactly the same data to the requester. Or it could be different altogether. Dealer’s choice. You can choose to have either or both depending on your application’s and your customers/consumers needs.

Anonymous 0 Comments

An API is simply how two things, software in this case, connect.

Once upon a time, every company that produced electricity had their own proprietary standard for how electrical devices would connect. This meant if you moved to the next town over, your toaster wouldn’t work and you would have to buy a new toaster( and lamp, and dishwasher, and…..) that worked with the new electrical company’s plug (assuming that the new cmpany even sells toasters) or you could try rewiring it yourself and hope not to burn your house down. Obviously this is madness.

At some point, countries standardized so that there is one plug (and voltage, and frequency) used in the US, one plug in the UK, one plug for most of Europe, etc. This means a standard interface for plugs, at least within a country.

An API is the same thing, but for software or web services. For instance, you could have software that tweets to certain people when something happens in the fire alarm system. This has been free and has had whole infrastructures built on this. Twitter is changing this to paid, which breaks lots of other software, and makes a lot of headaches for a lot of people.