# REST API / Content representation

**URL:** <https://forum.getkirby.com/t/rest-api-content-representation/15548>\
**Category:** Questions\
**Tags:** v3\
**Created:** [September 7, 2019, 3:17pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548 "2019-09-07T15:17:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gillesvauvarin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gillesvauvarin/32/2351_2.png) [@gillesvauvarin](https://forum.getkirby.com/u/gillesvauvarin)\
**Post date:** [September 7, 2019, 3:17pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/1 "2019-09-07T15:17:34Z")

</div>

Hello,

Could someone please explain to me the difference between REST API and Content Representation and in which use case we should use one or the other?

I read the documentation and this is what I’ve understood for the moment:

**REST API**

- Output data in JSON from endpoints
- Need authentication for security reason
- REST API is used to read, update, delete data

**Content Representation**

- Output data in JSON from representation template
- Don’t need authentication, data is publicly available through an URL
- Content Representation is only used to read data (no update/delete data possible)

Did I understand correctly?

What about the use case?

If I need to just read data or let anybody read data \> I should use Content representation  
If I need to let authorized user to read AND update/delete data, I should use the REST API …

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [September 7, 2019, 3:28pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/2 "2019-09-07T15:28:47Z")

</div>

yes i think so.

the rest api can take queries and return data in kirbys context (lots of data) and from your custom api endpoints (you custom data).

your custom content representations are as far as json goes just a simple way to dump an array. its limited to whatever you make it return.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 7, 2019, 3:37pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/3 "2019-09-07T15:37:10Z")

</div>

Content representations can output any type of data. A `.json` representation would return JSON data, but you are not limited to JSON representations. Your representations can return an RSS feed or whatever type of data you want it to return.

Typical use cases for JSON content representations are Ajax requests.

---

<div class="post-metadata">

**Author:** ![gillesvauvarin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gillesvauvarin/32/2351_2.png) [@gillesvauvarin](https://forum.getkirby.com/u/gillesvauvarin)\
**Post date:** [September 7, 2019, 3:43pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/4 "2019-09-07T15:43:31Z")

</div>

For instance, if I want to sourcing data from Kirby (use Kirby as a headless CMS) to output these data in a static generator to build a static website, what do you think is best ? REST API or Content Representation and could you tell me why?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 7, 2019, 3:46pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/5 "2019-09-07T15:46:36Z")

</div>

For use as a headless CMS, the REST API would be the right solution, because hat’s actually what the REST API is intended for. You might want to look into the [Better REST](https://github.com/robinscholz/better-rest) plugin.

---

<div class="post-metadata">

**Author:** ![gillesvauvarin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gillesvauvarin/32/2351_2.png) [@gillesvauvarin](https://forum.getkirby.com/u/gillesvauvarin)\
**Post date:** [September 7, 2019, 3:48pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/6 "2019-09-07T15:48:36Z")

</div>

Better Rest is a sort of boilerplate to help us using the Kirby API?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 7, 2019, 3:57pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/7 "2019-09-07T15:57:09Z")

</div>

Quoting @bnomei

> to all lovers of headless cms. @robinscholz and i joined forces and extended his better-rest plugin. [GitHub - robinscholz/better-rest: Kirby plugin for better REST requests](https://github.com/robinscholz/better-rest)  
> it makes the kirby 3 api availabe at `/rest` (readonly, auth required), has build in support for kirbytags, smartypants, multilanguage setups and srcset. even if the readme does not reflect this yet (stupid caches) i added unittests with build:passing and coverage:100 to make sure future updates won’t break your frontend.

---

<div class="post-metadata">

**Author:** ![gillesvauvarin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gillesvauvarin/32/2351_2.png) [@gillesvauvarin](https://forum.getkirby.com/u/gillesvauvarin)\
**Post date:** [September 7, 2019, 4:23pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/8 "2019-09-07T16:23:48Z")

</div>

Thanks, it’s still a bit confused in my head when use the REST API or the Representation, but I probably need to use them in a concrete project to understand.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 7, 2019, 5:07pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/9 "2019-09-07T17:07:07Z")

</div>

The REST API is already there for you to use. Why would you want to reinvent the wheel with content representations for the purpose of creating a static site?

---

<div class="post-metadata">

**Author:** ![gillesvauvarin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gillesvauvarin/32/2351_2.png) [@gillesvauvarin](https://forum.getkirby.com/u/gillesvauvarin)\
**Post date:** [September 7, 2019, 6:12pm UTC](https://forum.getkirby.com/t/rest-api-content-representation/15548/10 "2019-09-07T18:12:28Z")

</div>

Because the static generator Eleventy which I would like to use [https://www.11ty.io](https://www.11ty.io) can consume .json files as input data.

Representation provides .json files, REST API provides JSON object through a js file (if I understood correctly).
