DEV Community

Kupa
Kupa

Posted on • Originally published at ds.gtgroup.dev

Show DEV: Building Smartphone Specs API with .NET and Caddy

Mobile hardware specification APIs have long been messy and hard to integrate, largely due to incomplete and unnormalized data.

Raw strings as specs are frustrating to use in program logic. So, I built Device Specs API.


1. The Problem: Messy & Unstructured Data

If you've ever tried to integrate a specs API into your project, you've likely faced messy data, missing fields, or raw strings. For example:

  • Screen Refresh Rates: You want to show the refresh rate of a device to the user properly. Instead of an integer, you get a raw string like "6.7 inches, 120Hz LTPO OLED". Parsing a complex string just to get one number is a nightmare.
  • CPU Clock Speeds: It gets even crazier. An API returns: Octa-core (1x3.4 GHz Cortex-A725 & 3x3.2 GHz Cortex-A725 & 4x2.2 GHz Cortex-A725) Congratulations! Your simple feature just turned into a Regex lecture.

2. The Solution: Strongly-Typed, Normalized Data

I shifted the parsing heavy lifting to the backend server. The data returned to the user is clean, easy to consume, and strongly typed: numbers are numbers, lists are lists, texts are texts, and booleans are booleans.

When you request data for a device, the server returns normalized JSON:

  1. "battery_capacity": 5000 (integer, not "5000")
  2. "has_nfc": true (boolean, not "yes")
  3. Strongly-typed arrays for RAM and Storage options instead of raw blobs like "256GB 8GB RAM, 512GB 12GB RAM"

(If you ever need the raw format for legacy reasons, it's still available as an optional field!)


3. Deep Filtering

What if you want to query very specific hardware parameters without pulling unnecessary data?

That’s where Deep Filtering comes in. It allows you to query the dataset as deeply as possible directly through URL parameters.

For example, to find all devices with:

  • Battery capacity > 5000 mAh
  • RAM >= 8GB
  • Manufacturer is Samsung or Xiaomi
  • Model name contains "pro"

You just pass the pattern into the request URL:

?battery_gt=5000&ram_gte=8&manufacturer_in=samsung,xiaomi&model_contains=pro

Simple as that!


4. The Tech Stack & Architecture

  • Backend: ASP.NET Core Web API (.NET)
  • Frontend: Blazor WebAssembly / Server hybrid
  • Host: Ubuntu 24.04 + Docker
  • Reverse Proxy & SSL: Caddy
  • Data Format: Normalized JSON

5. Why Caddy Instead of Nginx?

I used Nginx for a while, but dealing with manual certbot setups and container configuration tweaks became tedious.

I switched to Caddy, which handles automatic HTTPS certificate management out of the box with zero manual cron jobs. The Caddyfile syntax is ultra-clean, minimal, and performance has been rock solid.


Try It Out

Full docs and live interactive testing are available here:

πŸ”— Device Specs API (ds.gtgroup.dev)

I’d love to get feedback from the DEV.to community on backend performance optimizations or features you'd like to see added!

Top comments (0)