Learning Objectives
By the end of this lesson you will be able to:
- Navigate the Calculator API challenge interface confidently
- Select the correct HTTP method and use the JSON template correctly
- Understand what each result type (Number, User input error, Application error) means for an API
- Know exactly when XP and the "API Adder" badge are awarded
A Different Kind of Challenge
Previous challenges in this course gave you simple input fields and a button. This one looks different — and that's intentional. The Calculator API challenge simulates what it feels like to call a real HTTP endpoint: you choose a method, craft a request body, and send it to a live API.
Don't let the new interface intimidate you. Everything you need to know is explained right here.
The Calculator API Interface
When you open the challenge, you see four main zones:
- A progress row at the top — six circles, one per test case. Filled circles are completed; the highlighted circle is your current case.
- A Method selector — a dropdown labelled "Select HTTP Method". For every test case in this challenge, the correct answer is POST.
- A JSON body editor — a text area where you enter the two input values as a structured JSON object with
"first"and"second"fields. - A Send button — submits the request and displays the result below.
The "Use JSON Template" Button
Below the method selector you'll find a "Use JSON Template" button. Clicking it fills the body editor with the ready-made structure:
{
"first": <number>,
"second": <number>
}
Replace <number> with the values the test case specifies. This is the fastest way to avoid formatting mistakes.
Understanding HTTP Methods
An HTTP method tells the server what kind of action you're requesting. In this challenge, you always use POST — the standard method for sending data to a server and expecting a computed response.
Why not GET? GET requests are for retrieving information, not sending input data. Selecting GET instead of POST will be flagged as incorrect straight away — the challenge checks your method choice before anything else.
The Three Result Types
After clicking Send, the API responds with one of three possible outcomes. Your job is to predict the correct one before you submit:
| Result | What it means |
|---|---|
| Number | The API successfully calculated and returned a numeric result |
| User input error | The input is invalid (e.g. text where a number is expected, or an empty field) — the API rejects it with a validation message before doing any math |
| Application error | The input looks valid but causes the API to behave unexpectedly — an overflow, an unhandled edge case, or a crash |
Pro Tip: "Application error" is the most interesting category for a tester. It means a value passed validation but broke something inside. These are the bugs that slip into production undetected.
The Six Test Cases
Each test case tells you exactly what values to put in the "first" and "second" fields. The six cases cover a representative set of input categories:
| Case | First | Second | Expected result | Why |
|---|---|---|---|---|
| 1 | 1 |
2 |
Number (3) | Happy path — two valid integers |
| 2 | -2 |
4 |
Number (2) | Negative number — still valid |
| 3 | 1.5 |
2.5 |
Number (4.0) | Decimal fractions — valid but a different type |
| 4 | abc |
1 |
User input error | Non-numeric string — validation should catch it |
| 5 | (empty) | (empty) | User input error | Both fields blank — nothing to calculate |
| 6 | 10000000000 |
1 |
Application error | Integer overflow — too large for the API to handle |
The challenge screen tells you what to enter for each case. You do not need to memorize this table.
Reading the Feedback
After clicking Send:
- All fields turn green — your method and values matched the expected inputs. The case is marked complete and you advance to the next circle.
- One or more fields turn red — something is off. The highlight shows you exactly which part was wrong. Correct it and try again.
No points are lost for incorrect attempts. The goal is learning, not punishment.
When Are XP and the Badge Awarded?
XP and the "API Adder" badge are awarded when you complete all 6 test cases in the challenge. There is no partial reward — the same principle as all BugEater challenges. A half-tested endpoint is still a liability.
Completing this challenge earns you 8 XP.
Pro Tips
- Always click "Use JSON Template" first. It inserts the correct JSON structure and saves you from formatting errors.
- For empty-field test cases (case 5), delete the placeholder text entirely — do not leave spaces.
- The method selector matters. Selecting GET instead of POST is treated as a wrong answer.
- If you're unsure between "User input error" and "Application error", ask yourself: "Would a well-written API even accept this input?" If the answer is no — it's a user input error. If yes but it still breaks — it's an application error.
What's Next
You understand the interface. You know the three result types. Now open the Calculator API (Addition) challenge and work through all 6 cases. The "API Adder" badge is waiting.