How to Connect a Gratuity Calculator API to Excel
Question details
The user wants to retrieve UAE end-of-service gratuity results directly into Excel by connecting to a third-party calculator API based on employee salary and service data.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Automating UAE end-of-service gratuity calculations by feeding employee details from a spreadsheet into an external third-party web API.
- Observed behavior
- Seeking a method to configure Excel to send data to an external API and fetch the resulting calculation, while facing concerns over the API's formula transparency.
Ensure that the third-party API you intend to use provides transparent documentation and complies with official UAE labor laws, as unverified external formulas cannot be reliably validated during an audit.
Use Power Query to Connect an Approved API
Power Query allows you to fetch data from a web API without writing code, making it the most accessible method for retrieving calculator results once you have a verified API.
Before proceeding, confirm that the API provider discloses their exact calculation formulas. If they do not, it is highly recommended to build a transparent formula manually in Excel using the documented UAE labor-law rules instead of relying on a black-box API.
Navigate to the 'Data' tab on the Excel ribbon, click on 'Get Data', select 'From Other Sources', and then choose 'From Web'.
Paste the specific API URL for the gratuity calculator in the dialog box, appending any necessary query parameters (such as salary and service length) required by the endpoint.
If the API requires authentication, enter your designated API key or access token in the web credentials prompt.
Use the Power Query Editor to parse the returned JSON response, extract the calculated gratuity value, and click 'Close & Load' to output the result into your worksheet.

Use VBA for Dynamic API Requests
If you need to fetch results for multiple employees simultaneously based on varying cell values, writing a custom VBA function offers greater flexibility.
Calculate Gratuity Securely with WPS Spreadsheets
Rather than relying on unverified third-party APIs for sensitive payroll calculations, WPS Office provides a free, lightweight alternative to build robust, transparent UAE gratuity calculation formulas locally. Enjoy high compatibility with Excel files, a familiar interface, and complete data privacy.
- 1. Download WPS Office: Visit the official WPS website and download the free installer for your operating system.
- 2. Install and Open: Run the setup file and launch WPS Spreadsheet to open your payroll documents.
- 3. Build Transparent Formulas: Use standard IF and VLOOKUP functions to accurately replicate UAE labor laws without risking data with third-party APIs.

Frequently Asked Questions
Why shouldn't I rely on a hidden third-party calculator API?
If an API does not disclose its underlying calculation formula, you cannot independently verify if it complies with the latest UAE labor laws. During financial audits, unverified formulas cannot be safely validated, making it risky for payroll management.
Can I calculate UAE gratuity locally without using an API?
Yes. By obtaining the exact UAE labor-law rules (such as basic salary, contract type, and service duration tiers), you can use nested IF and VLOOKUP functions to calculate the gratuity accurately and transparently within your spreadsheet.
What do I need to connect an approved API to Excel?
You will need the API's endpoint URL, any required authentication credentials (like API keys or tokens), and either Excel's Power Query feature or a VBA macro to send the web request and parse the returned JSON data.




