# Having a REST API

**URL:** https://discuss.tryton.org/t/having-a-rest-api/1603
**Category:** Ideas
**Created:** [July 24, 2019, 6:14am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603 "2019-07-24T06:14:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Herry](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/h/839c29/32.png) [@Herry](https://discuss.tryton.org/u/Herry)
#### Post date: [July 24, 2019, 6:14am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603/1 "2019-07-24T06:14:24Z")

</div>

Dear Sir,  
Instead of JSON-RPC, is it possible to have restfull api by Python for Web Client (vue.js), for example, a moudule similar to the following?

> **[GitHub - cristian-g/vsf-odoo: 💜 Odoo module for Vue Storefront](https://github.com/cristian-g/vsf-odoo)**
>
> 💜 Odoo module for Vue Storefront

> **[GitHub - vuestorefront/storefront-ui: A frontend library for React and Vue that helps...](https://github.com/vuestorefront/storefront-ui#readme)**
>
> A frontend library for React and Vue that helps developers quickly build fast, accessible, and beautiful storefronts. Made with 💚 by Vue Storefront team and contributors.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 24, 2019, 6:43am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603/2 "2019-07-24T06:43:34Z")

</div>

Any module can define its own routes like the [timesheet module](http://hg.tryton.org/modules/timesheet/file/default/routes.py). Of course it is not mandatory to use the [user application](http://docs.tryton.org/projects/server/en/latest/topics/user_application.html) decorator for authentication, you can use the `app.auth_required` which is the one used for the JSON-RPC.  
In case you want to implement a fully compatible RESTful, you should probably look at how it is done in `trytond.protocols.dispatcher._dispatch`.  
Also Tryton does not used RESTful by default because we want to have batch and context support which does not fit well in REST.

---

<div class="post-metadata">

### Author: ![Herry](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/h/839c29/32.png) [@Herry](https://discuss.tryton.org/u/Herry)
#### Post date: [July 24, 2019, 7:06am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603/3 "2019-07-24T07:06:34Z")

</div>

Thanks for your reply.  
One thing, it was said that the overall performance of REST would be better than JSON-RPC, what is your opinion? thanks.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 24, 2019, 7:18am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603/4 "2019-07-24T07:18:53Z")

</div>

No, the performance does not really depend on the protocol used but on how the procedure behind is implemented. Both protocols use HTTP and JSON (usually for REST) so there will be no difference in encoding/decoding.  
But as I said, REST does not really have an API for batch work like updating or creating many records at once. So if you plan to do such thing, our JSON-RPC will be faster because it will avoid client-server round-trip for each record.

---

<div class="post-metadata">

### Author: ![Herry](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/h/839c29/32.png) [@Herry](https://discuss.tryton.org/u/Herry)
#### Post date: [July 24, 2019, 7:30am UTC](https://discuss.tryton.org/t/having-a-rest-api/1603/5 "2019-07-24T07:30:53Z")

</div>

Understand, thanks a lot ！
