Amy Westlake

< Back to blog

Headless CMS's & API Driven Development

Note: I wrote this article as part of a job application.

What is a headless CMS?

Let’s take a standard CMS, it has a database, a backend UI and a frontend. In order to get the data out of the database you have to create a theme using the CMS’s language of choice which grabs the data and displays it in a web page. This is fairly standard but what if your website becomes popular and you decide you want to build an app version using the same data? What if you decided you wanted your site to be built using the latest fancy JavaScript framework? You’re limited to how the CMS allows you to get that data.

A “headless” CMS gets rid of the frontend and instead outputs an API with all of your data, leaving how you reach and display that data entirely up to you.

This means you can do whatever you want with that data; a website, native app, web app, widget, the possibilities are endless and you’re not just limited to one output. You could easily have a website and a native app running off the same API. You’d only have to update your content the once through the backend UI and the content would be updated across both the website and the native app.

You can’t predict future technology

No one knows what new device is around the corner so by being able to access your data through an API you are prepared whatever new way your data needs to be viewed. You are preparing for the future of the web by not limiting yourself to one application or coding language.

Can I use this for my projects?

While it may be a little overkill for a small brochure website it’s perfect for larger blogs or news sites. There are a number of headless CMS’s available such as Contentful, Prismic and even WordPress now offers the option to retrieve data through an API.

If you’re learning PHP and thinking of looking into Laravel, this is a great excuse to finally pick it up. With Laravel you can create API routes that simply return the data from your database, you could even create your own headless CMS with it.

Another benefit of creating your own API is that it helps you to really think about and understand your data and how it all relates.

Why you should learn to use API’s

API’s aren’t the first thing every new coder learns when picking up a new language, in fact I’d say it’s more of an intermediate/advanced skill to have, but once you understand the basics of GET & PULL requests it opens a lot more doors. You’ll be able to get data from sites such as Facebook, Twitter, YouTube, pretty much any large social network, and use it to display lovely content on your websites without having to use ugly widgets. There are of course much more practical uses for API’s but starting simple is the best way to learn.


< Back to blog