Learn

The Internal API

An internal abstraction layer that lets you do many things easily.

Statamic’s internal API is made up of over 100 methods spread across 22 objects. These objects and methods let you do a number of things, including file manipulation, URL examining, template parsing, and much more. This API is the very same that is used in Statamic’s core files. With everyone using the same API, you can rest assured that it’s well-maintained, relevant, and becoming more useful with each release.

Why Use the API

If you’re developing add-ons, it’s considered best practice to use the internal API for any tasks that you can. Although some methods are simply wrappers for standard PHP functions, many are not. The API gives developers a lot of power, and saves the core Statamic team from worrying about breaking add-ons with future updates.

The interface for API methods will mostly remain the same, although the underlying code may get refactored or reworked in some releases. By using the API, your add-on will automatically remain up-to-date and will instantly benefit from the refactored underlying code.

And if there comes a time where we do need to change the interface of existing API methods or objects, nothing will break right away. The core team will deprecate old methods with helpful information on how to update your code. As a developer, you will have a couple of Statamic core updates to update your add-ons before anything gets removed. We don’t anticipate this happening very often, but if it does, you should know that we’re still looking out for everyone.

Static Methods & Objects

The API is comprised entirely of static methods within objects. Objects are logical groupings of the methods they contain. For example, the File API object contains methods relating to file creation, manipulation, and removal.

Consult the API Documentation for a full list of objects and methods.

This article was last updated on September 13th, 2016. Find an error? Please let us know!