API generation

Probably a newbie question (sorry for that) but if I want to generate an API entry like below. Can I use the Business Logic module or I need to create a script in the Files Manager?
I am a bit unclear yet.
Endpoint: POST ratings
Description: assign a rating to a user and quote, in the ‘ratings’ table

    userId [mandatory]:id of the current user

    quoteId [mandatory]:id of the quote to be rated

    rating [mandatory]:int from 1 to 5

Processing: Rating is inserted into ‘ratings’ table and timestamped

Expected Output:
To the following request: /api/v1/ratings/?u=123&q=8945&r=3

    status = 200 if successful insert

    status = 400 if DB issue

Hi Tapuat,

yes, you can and should use Business logic for you purpose.
If you have questions on how to use it, do not hesitate to ask in this thread.


Should I use the ‘hosted’ in API services? If so, let’s say I use Javascript/Node, how do I create the right code for it? Following this? https://backendless.com/mobile-developers/quick-start-guide-for-javascript/

If you have pointers to documentation and samples that would be very helpful. :slight_smile:

Yes, you should use hosted services.
Here are some helpful links for you to start:

    documentation on api services: https://backendless.com/documentation/business-logic/js/apieng_overview.htm Sample of "Shopping Cart" written on NodeJS: https://github.com/Backendless/JS-Code-Runner/blob/master/examples/services/shopping-cart.js

I looked at the examples you gave me. Thank you.

Are the models/ files created by Backendless? I surmised they are directly related to the data declared in Backendless and would, therefore, be easily generated but maybe I am wrong?

No, the models are the classes you create which are used in your service signatures or within the implementation of your service. What’s generated is the actual REST API once you deploy the service.