Sync paginated account data via API

API toolWorkatoRecipe ToolsDeveloper ToolMarketingDatabase

What it does

When someone makes an API request, this automation queries SQL Server for account records and returns the requested page of results. The response includes the total count and pagination details so the caller knows how many records exist.

Who it's for

Engineering teams who need a paginated API endpoint to retrieve account data from SQL Server.

How teams use this

Retrieve accounts with page controls

Call the API with a page number to get a subset of accounts from SQL Server instead of all records at once. The response includes the total count so the caller can build pagination controls.

Integrate paginated data into a web app

Use this API endpoint in a web application to load accounts on demand as someone scrolls or clicks next. Only the page size and number change per request.

Filter accounts by status before pagination

Add a SQL condition to the count and fetch queries so only active or matching accounts are included in the total and page results. The pagination logic stays the same.

How it works

  1. Receive the API request. Someone calls the API endpoint with page number and size parameters. The automation defines what the request and response should contain.
  2. Prepare the query parameters. Execute Ruby code to format the page number and size into SQL Server query parameters so the database call works correctly.
  3. Count total accounts. Run a SQL query in SQL Server to count all filtered account records so the response can tell the caller how many exist.
  4. Fetch the current page. Run a SQL query in SQL Server to retrieve only the rows for the requested page based on the offset and limit.
  5. Build and return the response. Execute Ruby code to format the account rows, total count, and page details into the API response that the caller receives.