REST example
A tutorial on using rest to create an application with budibase
This tutorial builds a simple users app backed by a REST API.
Target architecture
- One REST connection (
Users API) - Four queries (
getUsers,getUser,createUser,updateUser) - One table view and two side-panel forms
Part 1: Prepare sample API
- Create a sample endpoint, such as MockAPI
- Add fields:
idnameaddresscreatedAt
- Copy the base URL
Part 2: Create connection
- Open Settings > Connections > APIs
- Click Add connection and choose Create custom
- Set the display name to
Users API - In Credentials, set the base URL
- Save the connection
- Click Open in API Editor
Part 3: Create CRUD queries
Create these queries:
getUsers:GET /usersgetUser:GET /users/{{id}}createUser:POST /usersupdateUser:PUT /users/{{id}}
For each query:
- Set method and path
- Configure bindings
- Configure the body for write queries
- Click Send
- Save query
Suggested request body for create/update
{
"name": "{{ name }}",
"address": "{{ address }}"
}Part 4: Build list screen
- Create a screen
- Add a table
- Set table data source to
getUsers - Add row-click actions:
- Update selected-row state
- Open edit side panel
Part 5: Edit existing user
- Add an edit side panel with a form for
nameandaddress - Set default values from selected-row state
- Add an Update button
- Button actions:
- Execute query
updateUser - Map
id,name,address - Refresh table
- Show success notification
- Close side panel
- Execute query
Part 6: Create new user
- Add an Add new user button
- Open a create side panel with the required fields
- Add a Save button
- Button actions:
- Execute query
createUser - Refresh table
- Clear form
- Show success notification
- Close side panel
- Execute query
Validation checklist
- Query tests return expected response codes
- The table loads initial data
- The edit flow updates the row and refreshes the UI
- The create flow inserts the row and refreshes the UI
- Error responses surface user-visible notifications
Common improvements
- Add a delete query and action (
DELETE /users/{{id}}) - Add client-side search and filtering
- Add form validation rules before execute-query actions
Related guides
Updated 4 months ago
Did this page help you?