How does an API work?

926 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

An API, especially in the context an online service, is a way for code to interface with that service. For instance, you could write a python script that posts tweets automatically, and the bit of code that actually posts the tweet is accessing Twitter’s API. In python, you could use the ‘tweepy’ library for this, which is a bunch of code that people have written to make this process easier. But under the hood, what is happening is basically that the code generates a long URL and then submits this over the internet. You could write this entire URL by hand (well, keyboard…), but it’s easier to automate it. The URL contains information about the server that you want to send the request to (Twitter), as well as details of that request – for instance, the command to post a tweet, the contents of that tweet, the credentials for the account that the tweet should be posted to, and so on. If you copied this URL and posted it into a browser, the same thing would happen: your request would be submitted to the Twitter API, and a tweet would be posted (if the request was successfully processed).

In short, it allows you to automate ways to interact with a service such as Twitter. So instead of hiring someone to write tweets, you can just have a script running on your computer. Of course this only works for content that can be generated automatically (or which you have created beforehand to be posted later). Like, I could write some code that, once every minute, requests the current temperature in New York from a weather service’s API, and then posts a tweet saying “It is currently X°C in New York!” (where X is the temperature we got from the weather service).

Maybe from this example you can already start to see the problem: if individuals and companies massively start using an API, sending requests to it all the time, then it will take a lot of server capacity to process all those requests. And servers costs money. So, a service like Twitter may decide that it’s no longer worth it for them to give away access to their API for free, and start charging people for it.

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