Yes, we built a paid API endpoint to check if a number is even. And yes, we're completely serious about it. Before you close this tab, hear us out - this is actually a story about modern software development, the npm ecosystem, and why "trivial" isn't always simple.
The Origin Story
If you've been on developer Twitter or Reddit, you've probably seen the is-even npm package memes. A package that checks if a number is even, with millions of downloads. The internet loves to mock it.
function isEven(n) {
return n % 2 === 0;
}
There. Done. One line. Why would anyone need a package - or an API - for this?
But Wait, It's Not That Simple
Here's where it gets interesting. Let's write a robust isEven function:
function isEven(n) {
// Handle non-numbers
if (typeof n !== 'number') {
if (typeof n === 'string') {
n = parseFloat(n);
} else {
throw new TypeError('Expected a number');
}
}
// Handle special cases
if (Number.isNaN(n)) return false;
if (!Number.isFinite(n)) return false;
// Handle floating point
if (!Number.isInteger(n)) {
throw new RangeError('Expected an integer');
}
// Handle BigInt-range numbers
if (n > Number.MAX_SAFE_INTEGER || n < Number.MIN_SAFE_INTEGER) {
// Convert to BigInt for accuracy
return BigInt(n) % 2n === 0n;
}
return n % 2 === 0;
}
Suddenly our one-liner became 25 lines. And we haven't even added:
- Proper TypeScript types
- JSDoc documentation
- Unit tests for edge cases
- Localization (some locales use comma as decimal separator)
- BigInt support
The Real Point
The isEven API isn't really about checking if numbers are even. It's about something bigger:
1. Edge Cases Are Everywhere
Even the simplest operations have edge cases. What happens when someone passes "42"? Or Infinity? Or NaN? Our API handles all of these gracefully.
2. Consistency Matters
When you use an API, you get consistent behavior across your entire application. No more subtle bugs where one developer handles edge cases differently than another.
3. It's Actually Useful for Learning
Our API returns detailed information that's perfect for educational purposes:
{
"number": 42,
"is_even": true,
"is_odd": false,
"binary": "101010",
"last_bit": 0,
"explanation": "42 is even because 42 % 2 = 0"
}
The Philosophy Behind TinyFn
This brings us to why TinyFn exists. We provide 500+ utility endpoints that handle edge cases, provide consistent behavior, and work across any language or platform. Our philosophy is:
- Don't reinvent the wheel - Use battle-tested implementations
- Focus on your core product - Let us handle the utilities
- Consistency across services - Same validation logic everywhere
- Zero dependencies - One API call, no npm packages needed
Who Actually Uses This?
Surprisingly, quite a few people:
- Educators teaching API concepts to students
- QA engineers testing API integrations
- No-code builders who can't write custom functions
- Developers who appreciate the humor and want consistent utilities
The Business Case
Our free tier gives you 100 requests/month. That's enough to check if 100 numbers are even. For free. Forever.
If you need to check more numbers, our Starter plan at $5/month gives you 10,000 requests. That's $0.0005 per number checked. Worth it? Probably not for isEven alone. But combine it with UUID generation, email validation, base64 encoding, and 500+ other endpoints? Now we're talking.
The Point We're Really Making
Building production-grade software is hard. Even "trivial" operations become complex when you account for:
- Input validation
- Error handling
- Edge cases
- Documentation
- Testing
- Maintenance
TinyFn handles all of that for you. We obsess over edge cases so you don't have to. And yes, that includes checking if numbers are even.
is-even npm package has over 200,000 weekly downloads. Our API handles that volume without breaking a sweat.
Try It Yourself
Go ahead, check if a number is even:
curl "https://api.tinyfn.io/v1/math/is-even?number=42" \
-H "X-API-Key: your-api-key"
Is it ridiculous? Maybe. Is it useful? Absolutely. Is it a conversation starter about software development practices? Definitely.
Ready to Check Some Numbers?
Get your free API key and access 500+ utility endpoints.
Get Free API Key