How does an API work?

968 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

Lots of great analogies here! I thought maybe seeing something a little more concrete might be helpful:

API stand for “Application Programming Interface.” Broadly, an API is a set of rules that on program must follow to talk to another program.

If I wrote a program to do math for you, I might set up an API that says your code must look like this:

compute(operation_symbol, number_1, number_2)

example:
compute(“+”, 2, 3)
returns:
5

Now, other programmers know what they need to give me and in what order: a symbol, a number, and another number. And they know what to expect in response: a number.

On the internet, it is common to create APIs based on URLs. A programmer can request a specific URL, and the website will return some information. For example, maybe Twitter creates an API for querying a user’s last tweet.

They will document that if you request

www.twitter.com/api/user={user_name}/last_tweet

They will send back to you something that looks like

{
“user” : “@A_Cool_Username”
“time” : “2022-12-31 03:21:12 EST”
“text” : “Happy new years everyone. Giving up Twitter for my resolution. Peace!”
}

So now, you can write a program that can query a bunch of usernames and know exactly what you’ll get back every time (predictability is very important for programming). That means you could write your own app or make a bot that always tweets back when a specific person tweets or whatever.

There is a lot more complexity here, obviously (don’t @ me programmers lol), but that’s the gist of an API.

Closing down the API will mean that all sorts of apps, bots, news feeds, etc that were setup to interface with twitter in different ways won’t work anymore.

You are viewing 1 out of 41 answers, click here to view all answers.