UiBuilder - Create REST API

Hi uibuilder users,

I want to implement a standard REST API with the usual verbs (GET, POST, PUT, DELETE) to manage a list of todos, for example. :

GET /todos
GET /todos/:id
POST /todos
PUT /todos/:id
DELETE /todos/:id
...

Can this be set up with uibuilder? Do you have a basic example? Is there a solution for simple authentication?

Do we have to go through the node-red http nodes?

Thanks for your advice!

Yes. The main feature would be the instance-specific API's.

With this feature, you can create your API endpoints as you've indicated and they are linked to a specific uibuilder node instance which defines the base URL.

I think there might have been an example of this shared in the forum a long time ago but because I don't currently use this feature in anger (it was added at the request of a uibuilder user some years ago), I don't have a specific example other than what is in the docs shared above.

UIBUILDER now has the same identity information that Dashboard 2 also has - this consists of standardised user and authentication information taken from standard HTTP headers used by typical external authentication services.

http://127.0.0.1:1880/red/uibuilder/docs/#/security/authenticated-client-properties

In addition, UIBUILDER provides client (browser) details to Node-RED including the source IP, a client ID that is stable for the life of the open browser, a tab id and the page name.

It also gives you access to a number of "hooks" in settings.js that lets you enhance or change client data and add security to messaging (something that normally isn't covered by "standard" security tools). You can also use the older but still effective middleware config feature of uibuilder but the hooks are easier to work with.

There really is no "one-size-fits-all" way of dealing with authentication and authorisation since there are so many options and requirements. UIBUILDER tries to ensure that you have easy access to the key data and process points so that you can easily build up your own requirements.

Nope! The whole point of UIBUILDER is to provide flexible, full featured but relatively easy to develop data-driven web applications. :smile:


Co-incidentally, I've been thinking about instance API's again recently and wondering whether I should introduce a more visible feature that would possibly mirror the core http-in/-response nodes but with a UIBUILDER flavour, ensuring that, for example, you get access to the comms and shared endpoints of uibuilder automatically.

Let me know if you think that would be helpful for a future release.

1 Like

Forgot to also say that, uibuilder also provides node-red with the full connection headers on client connect.

1 Like

Excellent, thank you very much Julian. That's exactly what I'm looking for!
I'm going to spend some time on it to learn more.

And yes, I think it's a good idea to make access to the API visible, accessible, adjusted and maybe driven via uibuilder. That's still my opinion, you'd have to ask for other opinions...

Thanks a lot.

Thanks for the feedback. It is a relatively complex thing to get right so may take some time to appear. However, the basics are already there.

By the way, should you need some server-side rendering support in your API's, that is possible too.