Blog·Craft·

Booleans are plain words

Why flags like bot and mobile use short names and JSON booleans, without prefixes or numeric codes to decode.

I want to be able to read an API response without keeping the docs open beside it. Field names do a lot of that work, especially when the answer is just yes or no.

These are a few fields from a mobile browser response on /useragent:

{
  "device": "mobile",
  "os": "Android",
  "browser": "Chrome Mobile",
  "bot": false,
  "mobile": true
}

mobile: true is enough. Adding is_ or _flag doesn't tell you anything else, and returning 1 would make you check whether it meant true or some category of device.

The same choice shows up in valid and disposable on email, and datacenter, relay, and tor in an IP's deep response. The field names describe what was checked, and JSON already has a type for the answer.

This also gives the fields a clear job as the API grows. The top-level bot stays a boolean. If you want the crawler's name and vendor, those details live in deep.bot. They don't replace the flag with an object and break the condition your app already uses.