# Demystifying the Craft CMS API


- Presented on: 04-Oct-2023
- Event: Dot All 2023
- Locations: Spain, Barcelona
- Slides: <iframe class="speakerdeck-iframe" style="border: 0px; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 315;" frameborder="0" src="https://speakerdeck.com/player/9469e83c0fc44fdba98d69219e6148a6" title=" Demystifying the Craft API for Twig Developers" allowfullscreen="true" data-ratio="1.7777777777777777"></iframe>
- Video: <iframe title="vimeo-player" src="https://player.vimeo.com/video/876545491?h=c38f8f0049&dnt=1" width="640" height="360" frameborder="0" allowfullscreen></iframe>
- Tags: Web Development, Craft
- URL: https://miranj.in/blog/2025/demystifying-the-craft-api


The [Pixel & Tonic][pnt] team were kind enough to invite me [back on the Dot All stage][da23][^1] to share some of our learnings with a room full of people in Barcelona. This time, I spoke about leveraging some of the power and tools that [Craft][craftcms] already ships with — filters, functions, collections, helpers, services, caches, and much more — right from within Twig.

The talk covers three broad areas:

- We start by looking at the benefits of leveraging Craft (and Yii) APIs in general and the ways in which that makes us more efficient developers, and our code more reliable and performant.

- Having established the *why,* we move on to examining commonly occurring scenarios during the development lifecycle and identifying patterns where we can start falling back to and integrating more of the API.

- In the third and final part, we look at ways to identify the appropriate Twig filters and functions, or Craft helpers, services, and components that can be plugged in these scenarios.

<div class="stretch clearfix" style="clear: both"><div class="embed-16-9">
<iframe title="vimeo-player" src="https://player.vimeo.com/video/876545491?h=c38f8f0049&title=0&byline=0&portrait=0" loading="lazy" frameborder="0" referrerpolicy="strict-origin-when-cross-origin" allow="autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share"   allowfullscreen></iframe>
</div></div>

<p class="caption"><a href="https://craftcms.com/events/dot-all-2023/sessions/demystifying-the-craft-api-for-twig-developers">
Demystifying the Craft API for Twig Developers by <i>Prateek Rungta</i></a> on <a href="https://vimeo.com/876545491">Vimeo</a>.</p>

In order to demonstrate some of these more richly with relatable examples, I created a bare-bones site for a fictional _Dot All Music Festival_. The [code for this site is up on GitHub](https://github.com/miranj/demystifying-craft-api).

<!-- and a demo version can be accessed in the browser as well -->

<p class="panel-2 stretch clearfix" markdown="1">
![Prateek speaking at Dot All 2023](https://miranj.in/media/talk/demystifying-the-craft-api/DotAll2023-Prateek.jpg)
![Audience listing to the "Demystifying the Craft CMS API" talk at  Dot All 2023](https://miranj.in/media/talk/demystifying-the-craft-api/DotAll2023-Audience.jpg)
</p>
<p class="caption" markdown="1">
  Photographs from the event.
</p>

This talk is based upon my own developer journey using Craft CMS over the years. I also drew from the experience of witnessing first-hand the individual development journeys of my teammates, and spotting common patterns between their paths and my own.

I hope this helps you discover and use more of the powerful tools available to use inside a Craft CMS Twig template file. [I would love to hear][mail] if you found any of the techniques useful or discovered something new that you could use.

[da23]:https://craftcms.com/events/dot-all-2023
[craftcms]:https://craftcms.com
[pnt]:https://pixelandtonic.com/ "Pixel & Tonic – the team behind Craft CMS"
[mail]:mailto:rungta@miranj.in

[^1]: We have previously delivered talks on [*Fortifying Craft CMS for High Traffic*](https://miranj.in/blog/2020/fortifying-craft-for-high-traffic) at Dot All 2019 in Montreal, and [*Modular Architecture for Building Content Websites*](https://miranj.in/blog/2019/modular-architecture-for-building-content-websites) at Dot All 2018 in Berlin.

*[CMS]: Content Management System
*[API]: