🔌
APIs for beginners
on programminglast updated 9/8/20
I think of APIs like Lego blocks. Programming has many different types of Lego blocks you can choose from — package managers are one shape, APIs are another, each comes in all kinds of colors, etc. — to make building stuff easier.
Conversely, you could manufacture your own blocks. You'd have to learn everything that dedicated Lego-makers have already figured out. You'd probably need to buy some miniature version of their fancy Lego-making equipment. Sounds like a lot of work. No longer are you restricted to this general set of blocks, but your new-found freedom comes at a high cost.
Maybe cooking is a better analogy. There are varying levels of "cooking" ranging from a simple sandwich of deli meats and packaged bread, to butchering the pig and baking your own sourdough.
One approach isn't inherently better than others, it completely depends on your goals. If you're aiming to create a super-fast internet search engine used by billions, a digital quesadilla IS. NOT. GOOD ENOUGH.
But when a purveyor of alligator-embossed apparel needs a search feature on their website, Algolia's API is perfect. Could Lacoste's engineers make this themselves? Maybe. But why should they? It's the equivalent of baking your own wedding cake — better left to the experts.
One last analogy. On any large team, each individual has a narrowly-defined job. They'll also have a very particular set of skills, skills they've acquired over a very long career, that would make it a nightmare for any rando plucked from a different department to replace them.
By virtue of specialization, the team becomes more than the sum of its parts and does more than they could with a roster of generalists. Similarly, APIs are all about focus.
The provider dedicates years to solving a difficult, though common problem: Stripe with online payments, Plaid with banking, Auth0 with authentication, and so on. That's all they work on.
Eventually, the API provider finds a decent solution to this problem and then shares it with the world. Their solution is an API (often a set of APIs), or publicly-available chunks of code that other developers get to copy and paste. In the writing world, this is called plagiarism. In programming, it's encouraged.
Because of the API provider's toil, customers don't need to spend months of their engineering team's time (easily a 5 or 6 figure cost) for a solution to accepting credit card payments... that might work. Weighed against ~3% and $0.30 per transaction, no up-front cost, and guaranteed support on the off-chance it ever doesn't work, the decision is easy.
Back in the 1400s, the printing press was a revolutionary technology. It made mass production of books and newspapers possible, laying ground for The Renaissance in the following centuries.
Today, we often conflate 'technology' with hardware or software, but technology is really anything that makes something simpler. Technology is a form of abstraction (abstraction = removing non-essential details), which is why I think abstraction within the process of developing software, already a powerful technology / abstraction itself, is so interesting.
I'm definitely not the best person to explain the history of software development, just let me quickly share a few recent highlights.
Before 2006, tech companies had to buy and manage their own servers. I've read that this was complicated and annoying, which is why AWS has become an ATM for Amazon. Renting someone else's servers saves a ton of headaches.
Around that same time, Git was also released. Its inception meant that developers could finally track changes to their code and restore older versions (like Google Docs). GitHub and GitLab are popular products built around this system, enabling teams of developers to collaborate on files stored online, instead of on their individual computers.
AWS allowed engineering teams to focus on coding their apps, not managing servers. GitHub made it easier for these teams to collaborate. APIs let engineering teams and individual devs further narrow their scope and only code the most important parts of their apps.
Like Infrastructure-as-a-Service (AWS) and remote version control (GitHub), APIs are an important abstraction in the world of software development. It's really hard to make something easy, and APIs make it easier to create.