DEV Community

Cover image for I got tired of the official EU VAT API crashing, so I built a Serverless wrapper with Webhooks 🚀
Quicreatdev
Quicreatdev

Posted on

I got tired of the official EU VAT API crashing, so I built a Serverless wrapper with Webhooks 🚀

Hello DEV community! 👋

If you've ever built a B2B SaaS or an e-commerce checkout in Europe, you know the struggle. By law, you have to validate your customers' VAT numbers to apply the reverse charge mechanism.

The official way to do this is via the European Commission's VIES API. But there are a few huge problems with it:

  1. It frequently crashes or rate-limits you during business hours.
  2. It's incredibly slow.
  3. The biggest issue: It only tells you the status today. If your biggest client goes bankrupt or closes next month, you won't know until the unpaid invoices pile up.

I wanted a modern, fast, and proactive solution. So, I built VatFlow.

🛠 What I built

VatFlow is a REST API hosted on RapidAPI that acts as a smart shield and monitor for B2B company data.

Here is what makes it different:

  • ⚡️ Smart Caching: I built a DynamoDB caching layer. If you request a VAT number that was recently checked, it returns in milliseconds. No more VIES downtime impacting your checkout flow.
  • 🔔 Real-time Webhooks: This is the feature I'm the most proud of. You can subscribe to a VAT number. Every night, my serverless cron job checks the company's status. If they close down or change their address, your server gets a POST request instantly.
  • 🇫🇷 Deep Enrichment (France): For French companies, the API automatically enriches the VIES data with financial data (revenue, net income) and executives' names using local Open Data.

🏗 The Tech Stack (100% Serverless)

I wanted this to be infinitely scalable and cost-effective, so I went all-in on AWS Serverless:

  • API Gateway & AWS Lambda (Node.js) for the endpoints.
  • DynamoDB for the lightning-fast caching and storing webhook subscriptions.
  • DynamoDB Streams & EventBridge to detect changes in the data and automatically trigger the webhook dispatcher.

💻 Developer Experience First

I know how annoying it is to integrate a new API. So alongside the launch, I published two official, zero-dependency wrappers with built-in auto-retry mechanisms (because network glitches happen).

For Node.js (npm):

npm install vatflow

Enter fullscreen mode Exit fullscreen mode
const VatFlowClient = require('vatflow');
const client = new VatFlowClient('YOUR_RAPIDAPI_KEY');

// Validate a VAT number in one line
const result = await client.validate('FR14652014051');
console.log(result.data.name);

Enter fullscreen mode Exit fullscreen mode

For PHP (Composer):

composer require quicreatdev/vatflow-php

Enter fullscreen mode Exit fullscreen mode

🎁 Try it out!

I've published the API on RapidAPI with a Free Tier so you can test it without putting down a credit card.

👉 Check out VatFlow on RapidAPI here

I would absolutely love to hear your feedback on the architecture, the DX, or the RapidAPI integration. Have you ever struggled with the VIES API before? Let me know in the comments! 👇

Top comments (0)