<p>If you only need to create a JSON API for fetching existing entries, etc., check out the <a href="https://github.com/pixelandtonic/ElementAPI">Element API</a> plugin.</p>

CC BY-SA 3.0
2015-08-19T18:06:14.300Z
2015-08-19T18:06:14.300Z
Brandon Kelly
<p>No, Craft doesn't have a REST API (edit: or any other web service) built-in. The "API" mentioned in the first quote (and elsewhere related) would be the more generic meaning of the term and refers to the <a href="https://buildwithcraft.com/classreference#craft.app.services" rel="nofollow noreferrer">service layer</a>.</p>

<p>With a very consistent MVC based architecture based on <a href="http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/" rel="nofollow noreferrer">Yii</a>, Craft is well suited for REST implementation, though. See <a href="https://plus.google.com/108374347584100012430/posts/3v9MSFhT8nr" rel="nofollow noreferrer">this G+ thread</a> for P&amp;T weighing in on the subject.</p>

<p>As a native REST API isn't part of the core, one would have to added to Craft via a <a href="http://buildwithcraft.com/docs/plugins/introduction" rel="nofollow noreferrer">plugin</a>. </p>

<p>There's at least <a href="https://github.com/wesrice/rest-easy" rel="nofollow noreferrer">one plugin out there</a>, though I haven't tried it (or any others) myself.</p>

<p><strong>Edit</strong></p>

<p>It should be mentioned that after I wrote the above answer, Pixel and Tonic has released the <a href="https://github.com/pixelandtonic/ElementAPI" rel="nofollow noreferrer">Element API plugin</a> - making it easy to build a REST API with Craft. Element API is pretty basic (only GET requests), but can probably be extended with a custom plugin to support additional HTTP methods.</p>

<p>P&amp;T has also stated that they want Craft 3 to have a full, built-in REST API at some point.</p>

CC BY-SA 3.0
2015-04-22T09:41:29.110Z
So when he says "including other services" then he is not talking about third party services?
Magne
CC BY-SA 3.0
2015-04-22T09:43:48.970Z
No, as in "other Craft services", would be my interpretation. Notice the "anything else _in the system_" part.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-22T09:46:32.350Z
Ah, ok. That makes sense.
Magne
CC BY-SA 3.0
2015-04-22T09:49:07.103Z
Do you know if it has any other kind of API for third-parties? SOAP? RPC?
Magne
CC BY-SA 3.0
2015-04-22T09:58:38.523Z
No, there aren't any web services shipped with Craft. Might be worth a [feature request](http://feedback.buildwithcraft.com/forums/285221-feature-requests).
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-22T10:21:59.553Z
You might want to look into [what Yii has to offer](http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice), though.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-22T10:48:07.570Z
Thanks, I will look into rest-easy, and maybe using cURL to simulate a normal user interacting with Craft CMS and POST'ing the data through the forms inside the CMS itself.
Magne
CC BY-SA 3.0
2015-04-22T10:50:00.080Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/23077/discussion-between-mmikkel-and-magne).
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-22T09:34:50.307Z
2017-07-23T06:11:07.320Z
2017-07-23T06:11:07.320Z
Mats Mikkel Rummelhoff
<p>Does Craft CMS have an API that third-party webapps can access? </p>

<p>Maybe a REST API which you can log in to and send GET, PUT, POST, DELETE commands to, from a third-party app?</p>

<p>It seems like it should have an API, by the statement of the creator:</p>

<blockquote>
  <p>A key part of the architecture is our service layer. All of the
  business logic in Craft happens in service classes, which provide APIs
  that anything else in the system (including other services) can talk
  to.
   - <a href="http://www.thenerdary.net/post/48123188844/interview-with-brandon-kelly-creator-of-craft">http://www.thenerdary.net/post/48123188844/interview-with-brandon-kelly-creator-of-craft</a></p>
</blockquote>

<p>But then again, some other people who have tried integrating towards Craft CMS says it doesn't:</p>

<blockquote>
  <p>I ran into some trouble with the API. Shit, Craft doesn’t freakin’
  have one! I assumed it would, oops.. So I researched how to do it. I
  knew I could probably fake it and output json using template tags but
  no-one wants to do that. I looked at some API controllers but non of
  them worked very well. In the end I found a nice plugin called JSON
  Expand that converts entries from Twig into JSON. - 
  <a href="http://abandon.ie/notebook/using-angularjs-with-craft-cms">http://abandon.ie/notebook/using-angularjs-with-craft-cms</a></p>
</blockquote>

<p>I'm confused. If it has an API, what kind is it, and what protocol does it use? REST? SOAP? RPC? Something else?</p>

<p>And where is it documented? A simple 'hello world' or 'transmit som data into Craft CMS' example would be really helpful.</p>

<plugin-development><routes>
Does Craft CMS have an API?
# Does Craft CMS have an API?

(Asked by: username_0 on 2015-04-22)

Does Craft CMS have an API that third-party webapps can access?

Maybe a REST API which you can log in to and send GET, PUT, POST, DELETE commands to, from a third-party app?

It seems like it should have an API, by the statement of the creator:

> A key part of the architecture is our service layer. All of the
> business logic in Craft happens in service classes, which provide APIs
> that anything else in the system (including other services) can talk
> to.
> - <http://www.thenerdary.net/post/48123188844/interview-with-brandon-kelly-creator-of-craft>

But then again, some other people who have tried integrating towards Craft CMS says it doesn't:

> I ran into some trouble with the API. Shit, Craft doesn’t freakin’
> have one! I assumed it would, oops.. So I researched how to do it. I
> knew I could probably fake it and output json using template tags but
> no-one wants to do that. I looked at some API controllers but non of
> them worked very well. In the end I found a nice plugin called JSON
> Expand that converts entries from Twig into JSON. -
> <http://abandon.ie/notebook/using-angularjs-with-craft-cms>

I'm confused. If it has an API, what kind is it, and what protocol does it use? REST? SOAP? RPC? Something else?

And where is it documented? A simple 'hello world' or 'transmit som data into Craft CMS' example would be really helpful.

**Tags:** plugin-development, routes


---

## 2 answers

### Answer by username_2 on 2015-04-22. Score: 9 | Accepted answer

No, Craft doesn't have a REST API (edit: or any other web service) built-in. The "API" mentioned in the first quote (and elsewhere related) would be the more generic meaning of the term and refers to the [service layer](https://buildwithcraft.com/classreference#craft.app.services).

With a very consistent MVC based architecture based on [Yii](http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/), Craft is well suited for REST implementation, though. See [this G+ thread](https://plus.google.com/108374347584100012430/posts/3v9MSFhT8nr) for P&T weighing in on the subject.

As a native REST API isn't part of the core, one would have to added to Craft via a [plugin](http://buildwithcraft.com/docs/plugins/introduction).

There's at least [one plugin out there](https://github.com/wesrice/rest-easy), though I haven't tried it (or any others) myself.

**Edit**

It should be mentioned that after I wrote the above answer, Pixel and Tonic has released the [Element API plugin](https://github.com/pixelandtonic/ElementAPI) - making it easy to build a REST API with Craft. Element API is pretty basic (only GET requests), but can probably be extended with a custom plugin to support additional HTTP methods.

P&T has also stated that they want Craft 3 to have a full, built-in REST API at some point.

> **Comments:**
> **username_0**: So when he says "including other services" then he is not talking about third party services?  
> **username_2**: No, as in "other Craft services", would be my interpretation. Notice the "anything else _in the system_" part.  
> **username_0**: Ah, ok. That makes sense.  
> **username_0**: Do you know if it has any other kind of API for third-parties? SOAP? RPC?  
> **username_2**: No, there aren't any web services shipped with Craft. Might be worth a [feature request](http://feedback.buildwithcraft.com/forums/285221-feature-requests).  
> **username_2**: You might want to look into [what Yii has to offer](http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice), though.  
> **username_0**: Thanks, I will look into rest-easy, and maybe using cURL to simulate a normal user interacting with Craft CMS and POST'ing the data through the forms inside the CMS itself.  
> **username_2**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/23077/discussion-between-mmikkel-and-magne).  

---

### Answer by username_1 on 2015-08-19. Score: 6

If you only need to create a JSON API for fetching existing entries, etc., check out the [Element API](https://github.com/pixelandtonic/ElementAPI) plugin.


---

