# Best way to Include API in cakephp MVC

**URL:** <https://discourse.cakephp.org/t/best-way-to-include-api-in-cakephp-mvc/9633>\
**Category:** Uncategorized\
**Created:** [August 14, 2021, 12:18pm UTC](https://discourse.cakephp.org/t/best-way-to-include-api-in-cakephp-mvc/9633 "2021-08-14T12:18:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagguy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jagguy](https://discourse.cakephp.org/u/jagguy)\
**Post date:** [August 14, 2021, 12:18pm UTC](https://discourse.cakephp.org/t/best-way-to-include-api-in-cakephp-mvc/9633/1 "2021-08-14T12:18:10Z")

</div>

I have a xero API that we access via a component in a controller . This works but accessing data is complicated. The models we use need to access data from xero api call and so we are going back and forward from controller to model in collecting data. My question is what is the best way to connect an API to xero.

We want to be able to collect data from a model and that might mean at times accessing xero api calls from a model as well. In cakephp to access API do we do this via components/models … whats the best way?

---

<div class="post-metadata">

**Author:** ![jagguy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jagguy](https://discourse.cakephp.org/u/jagguy)\
**Post date:** [August 17, 2021, 1:16pm UTC](https://discourse.cakephp.org/t/best-way-to-include-api-in-cakephp-mvc/9633/2 "2021-08-17T13:16:54Z")

</div>

The simplest way I found seems to just use a generic controller to filter out calls to specific APIs in their own model/controllers
