Static delivery, dynamic generation: the case for flat-file APIs

The Jamstack movement pushed plenty of sites toward pre-rendered static files, and the same reasoning can be applied to content-based APIs. As Sean C Davis explains, a static API is "a collection of flat JSON files that live on a content delivery network (CDN)." Its only job is handing those files to whoever requests them.

That constraint says nothing about how the content gets made. According to Davis, files never have to be written by hand, and a static API "can still use a database and it can still pull data from external services" — it can be dynamically generated while remaining statically delivered. Nor is the result necessarily simple.

Applications for the pattern are somewhat limited, the source acknowledges, but it has an appealing shape. RSS and, more directly, JSON feeds fit naturally: a number of feeds already work this way, among them implementations built with the Eleventy plugin.