What is API?
So a friend comes up to you and says
"I heard you create websites. Can you make me one?"
You, being a good friend, happily agree. You agree on the details and you get cracking with the website…
After a month or so, you complete the work. You show the website to your friend.
Your friend is mindblown! His pupils dilate at the site of his new amazing website that you have built for him.
You have the feeling of pride that your creation has made your close friend happy
After a few days, you get a phone call from your friend:
"Hey! Remember you made a website for me? It's great! But I have a Twitter account, and I was wondering if you could add the number of followers at the top right?"
You think it's a great idea so you agree to do it!
Thing is, how are you going to grab the number of followers and add it to his website?
You put your brain to work on possible ways…
Should you hardcode the number of followers to the website?
Sure that could work, BUT…
Are you willing to constantly get to the website's code and change that number?
No? Then that's probably not the answer…
Should you somehow automatically go to your friend's Twitter profile regularly, grab the follower count and put in on the website?
Sure that's a viable option. But it's an unstable solution that will become useless once Twitter decides to change to their website.
You need to somehow have Twitter send this information to you in a reliable way.
Thankfully, Twitter has a functionality to easily get and post information such as tweets, followers and other useful stuff.
Such a tool is called an API (Application Programming Interface)!
So you read through the documentation of the Twitter API and sure enough, there's a easy way to grab the follower count of your friend's account with just a URL.
So you set up a scheduled process which grabs the follower count and adds it to your friend's website.
Finally you show this to your friend and once again, he is happier than ever!
A job well done!
APIs are basically a façade programmers can use to make accessing a complex system easier.
APIs are tools used by almost all popular websites. Here are some examples:
I hope this article made API a little easier to understand. Thank you for reading! 👋👋👋
Explained (22 part series)
- Accessibility, explained.
- React, explained
- Should I use forEach() or map()?
- Should I use Flexbox or CSS Grid?
- Docker, explained.
- Unit testing, explained
- Git, explained.
- Typescript, explained.
- async/await, explained.
- The DOM, explained.
- Regular expressions, explained
- GraphQL, explained.
- Vue, explained.
- Svelte, explained.
- API, explained.
- Immediately Invoked Function Expressions (IIFE), explained.
- ARIA roles, explained.
- Test-driven Development, explained.
- ARIA live regions, explained.