Bird
0
0

You are designing a REST API for a weather service. To improve usability, which approach best ensures consistent data format for temperature readings?

hard📝 Application Q15 of 15
Rest API - Request and Response Format
You are designing a REST API for a weather service. To improve usability, which approach best ensures consistent data format for temperature readings?
AReturn temperature sometimes in Celsius, sometimes in Fahrenheit based on client location.
BAlways return temperature as a number in Celsius with a fixed decimal format.
CReturn temperature as a string with units included, e.g., '20°C' or '68°F'.
DReturn temperature as raw sensor data without any formatting.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the need for consistent numeric format

    Returning temperature as a number in a fixed unit and decimal format helps clients process data uniformly.
  2. Step 2: Evaluate other options for consistency

    Mixing units or returning strings with units complicates parsing and may cause errors.
  3. Final Answer:

    Always return temperature as a number in Celsius with a fixed decimal format. -> Option B
  4. Quick Check:

    Consistent numeric format improves usability = A [OK]
Quick Trick: Use fixed units and numeric format for easy client parsing [OK]
Common Mistakes:
  • Mixing units based on client location
  • Returning temperature as strings with units
  • Sending raw unformatted sensor data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes