واجهة برمجة حاسبة ضريبة القيمة المضافة

احسب المبلغ الصافي والإجمالي ومبلغ ضريبة القيمة المضافة ومعدلها لأي بلد في استدعاء واحد منظم.

ماذا يمكنك أن تفعل؟
الفواتير والإيصالات

احسب بنود ضريبة القيمة المضافة للفواتير وعروض الأسعار والإيصالات فوراً.

عمليات الدفع في التجارة الإلكترونية

اعرض الأسعار شاملة الضريبة وتفصيل واضح لضريبة القيمة المضافة عند الدفع.

البرمجيات كخدمة والاشتراكات

وحّد حسابات ضريبة القيمة المضافة عبر البلدان والعملات والحالات الخاصة.

99.9 % وقت التشغيل
2.6ms الاستجابة
20 req/s
0.001 الأرصدة / الطلب

VAT API


POST https://api.yeb.to/v1/vat
المعامل النوع مطلوب الوصف
api_key string نعم Auth key
action string اختياري calculate (default) | list-countries | country-profile | country-rates
net number|string اختياري Net amount (price excluding VAT). Provide at least two of: net, gross, vat_amount, vat_rate.
gross number|string اختياري Gross amount (price including VAT).
vat_amount number|string اختياري VAT amount.
vat_rate number|string اختياري VAT rate as percentage (e.g. 20) or fraction (e.g. 0.20). If present, this always overrides country defaults.
country_code string اختياري 2-letter ISO code (e.g. BG, DE, FR). Used for currency, rounding and default VAT rates.
vat_type string اختياري standard | reduced | super_reduced | zero. Used when deriving rate from country_code.
decimal_separator string اختياري Output decimal separator: . (default) or ,. Input values accept both . and ,.
round bool اختياري Whether to apply rounding as per country profile (default: true).
advanced bool اختياري When true and no explicit vat_rate is provided, returns multi-rate scenarios for the country (scenario_type = "multi_rate").

أمثلة الطلبات

# Simple VAT calculation (custom 20% rate)
curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&net=100&vat_rate=20&country_code=BG&vat_type=standard"
# Let the API pick the default rate for BG (no explicit vat_rate)
curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&net=100&country_code=BG&vat_type=standard"

تكاملات API

curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&net=100&vat_rate=20&country_code=BG&vat_type=standard"
use Illuminate\Support\Facades\Http;

Route::post('/vat-example', function () {
    $response = Http::asForm()->post('https://api.yeb.to/v1/vat', [
        'api_key'      => config('services.yeb.key'),
        'action'       => 'calculate',
        'net'          => 100,
        'vat_rate'     => 20,
        'country_code' => 'BG',
        'vat_type'     => 'standard',
    ]);

    return $response->json();
});
$response = Http::asForm()->post('https://api.yeb.to/v1/vat', [
    'api_key'      => 'YOUR_KEY',
    'action'       => 'calculate',
    'net'          => 100,
    'vat_rate'     => 20,
    'country_code' => 'BG',
    'vat_type'     => 'standard',
]);

$data = $response->json();
const params = new URLSearchParams({
  api_key: 'YOUR_KEY',
  action: 'calculate',
  net: '100',
  vat_rate: '20',
  country_code: 'BG',
  vat_type: 'standard'
});

fetch('https://api.yeb.to/v1/vat', {
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  body: params.toString()
})
  .then(r => r.json())
  .then(console.log);
import requests

payload = {
    "api_key": "YOUR_KEY",
    "action": "calculate",
    "net": 100,
    "vat_rate": 20,
    "country_code": "BG",
    "vat_type": "standard",
}

r = requests.post('https://api.yeb.to/v1/vat', data=payload)
print(r.json())

Response Example

{
  "country_code": "BG",
  "vat_type": "standard",
  "scenario_type": "single_rate",
  "net": 100,
  "gross": 120,
  "vat_amount": 20,
  "vat_rate": 0.2,
  "vat_rate_percent": 20,
  "decimal_separator": ".",
  "currency": "BGN",
  "rounding": { "precision": 2, "mode": "half_up" },
  "warnings": [],
  "formatted": {
    "net": "100.00",
    "gross": "120.00",
    "vat_amount": "20.00",
    "vat_rate": "20.00%"
  },
  "response_code": 200,
  "response_time_ms": 5
}
{
  "error": "Missing \"country_code\" parameter",
  "code": 400,
  "response_code": 400,
  "response_time_ms": 3
}

رموز الاستجابة

الرمزالوصف
200 Successتمت معالجة الطلب بنجاح.
400 Bad Requestفشل التحقق من المدخلات.
401 Unauthorizedمفتاح API مفقود أو خاطئ.
403 Forbiddenالمفتاح غير نشط أو غير مسموح.
429 Rate Limitطلبات كثيرة جدًا.
500 Server Errorفشل غير متوقع.

Calculate

vat 0.0010 credits

Parameters

API Key
body · string · required
Action
body · string
Net amount
body · string
Gross amount
body · string
VAT amount
body · string
VAT rate
body · string
Country code
body · string
VAT type
body · string
Decimal separator
body · string
Round amounts
body · string
Advanced mode
body · string

Code Samples


                
                
                
            

Response

Status:
Headers

                
Body

                

واجهة برمجة حاسبة ضريبة القيمة المضافة — Practical Guide

A practical guide to واجهة برمجة حاسبة ضريبة القيمة المضافة: how to calculate VAT from any combination of net, gross, VAT amount or rate, how to leverage country profiles, and how to read both single-rate and multi-rate scenarios in your billing or invoicing logic.

#What the VAT API solves

Instead of re-implementing VAT rules in every project, you send net / gross / VAT amount / rate (any two are enough), plus optional country and VAT type. The API calculates the missing numbers, applies country-specific rounding, and can even return multi-rate scenarios when you need to compare standard vs reduced rates.

#Endpoint & actions

#POST https://api.yeb.to/v1/vat

  • Single endpoint with an action parameter.
  • Idempotent: same input → same result; safe for caching and retries.
  • Supports both: form-encoded requests (application/x-www-form-urlencoded) and JSON bodies (when valid JSON is sent from your backend).
ActionUse it forNotes
calculate (default) Compute net/gross/VAT from any two inputs. Typical cart / line-item calculations; supports custom or country-default rates.
list-countries Get a list of configured countries. Returns country code, name and currency; ideal for dropdowns.
country-profile Inspect VAT configuration for a single country. Includes currency, rounding and VAT rates by type.
country-rates Get only the rates grouped by type. Simpler, compact response when you already know the rest.

#Quick start examples

# 1) Custom VAT rate (20%), net → gross
curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&net=100&vat_rate=20&country_code=BG&vat_type=standard"
# 2) Use default rate from BG profile (no explicit vat_rate)
curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&net=100&country_code=BG&vat_type=standard"
# 3) Advanced multi-rate scenarios for a country
curl -s -X POST "https://api.yeb.to/v1/vat" ^
  -H "X-API-Key: YOUR_KEY" ^
  -H "Content-Type: application/x-www-form-urlencoded" ^
  --data "action=calculate&advanced=1&net=100&country_code=DE"

#Parameters that actually matter

ParamRequiredWhat to pass in practiceWhy it matters
api_key Yes Send from server/edge, never directly from public JS. Authentication, rate limiting, and credit charging.
action No Default is calculate. Use other actions for metadata only. Controls which logical operation the API performs.
net For calculate: at least 2 of net/gross/vat_amount/vat_rate Net price (excl. VAT), as number or string; , and . are both accepted. Primary monetary input in most billing flows.
gross Same Gross price (incl. VAT). Often known when reverse-engineering net values. Useful for “VAT included” pricing.
vat_amount Same When you know how much VAT was charged and want to infer the rest. Typical for imported accounting data.
vat_rate Same Your own custom rate: 20 (=20%) or 0.2. If present, it overrides country defaults. Gives you full control over the percentage.
country_code No (but required for country-* actions) 2-letter ISO code (e.g. BG, DE, FR). Used for currency, default rates and rounding rules.
vat_type No standard by default; use reduced, super_reduced, or zero where relevant. Selects which rate from the country profile to use.
decimal_separator No . (default) or , for formatted values. Controls the formatted block in the response.
round No 1/true to enable (default), 0/false to disable. Decides whether amounts are rounded according to the country profile.
advanced No Set to 1 to get multi-rate scenarios when no explicit vat_rate is given. Handy for “what-if” comparisons across standard/reduced rates.

#Reading & acting on responses

#Single-rate scenario (scenario_type = "single_rate")

{
  "country_code": "BG",
  "vat_type": "standard",
  "scenario_type": "single_rate",
  "net": 100,
  "gross": 120,
  "vat_amount": 20,
  "vat_rate": 0.2,
  "vat_rate_percent": 20,
  "decimal_separator": ".",
  "currency": "BGN",
  "rounding": { "precision": 2, "mode": "half_up" },
  "warnings": [],
  "formatted": {
    "net": "100.00",
    "gross": "120.00",
    "vat_amount": "20.00",
    "vat_rate": "20.00%"
  },
  "response_code": 200,
  "response_time_ms": 5
}
  • net, gross, vat_amount — numeric fields you can store directly in your DB.
  • vat_rate, vat_rate_percent — the effective rate used (fraction and %).
  • formatted — strings ready for UI/PDF output with the chosen decimal_separator.
  • warnings — non-fatal hints (e.g. not enough data) that you may show to admins or logs.

#Multi-rate scenarios (scenario_type = "multi_rate")

{
  "country_code": "DE",
  "vat_type": "standard",
  "scenario_type": "multi_rate",
  "net": 100,
  "gross": null,
  "vat_amount": null,
  "decimal_separator": ".",
  "currency": "EUR",
  "rounding": { "precision": 2, "mode": "half_up" },
  "warnings": [],
  "scenarios": [
    {
      "vat_type": "standard",
      "vat_rate": 0.19,
      "vat_rate_percent": 19,
      "net": 100,
      "gross": 119,
      "vat_amount": 19,
      "formatted": { "...": "..." }
    },
    {
      "vat_type": "reduced",
      "vat_rate": 0.07,
      "vat_rate_percent": 7,
      "net": 100,
      "gross": 107,
      "vat_amount": 7,
      "formatted": { "...": "..." }
    }
  ]
}
  • Use scenarios to compare different VAT types for the same net amount.
  • Ideal for admin UIs where you show “standard vs reduced” on the same screen.
  • Pick one scenario and persist only that to your invoice rows.

#Typical errors & how to fix them

{ "error": "Missing \"country_code\" parameter", "code": 400 }
{ "error": "Invalid API key", "code": 401 }
{
  "country_code": null,
  "scenario_type": "single_rate",
  "net": null,
  "gross": null,
  "vat_amount": null,
  "vat_rate": null,
  "warnings": [
    "Not enough information to compute VAT. Provide at least two of: net, gross, vat_amount, vat_rate (or a country_code with rates)."
  ],
  "formatted": null
}
  • 401 invalid/missing key: pass api_key or X-API-Key from your backend.
  • 400 missing country_code: required for country-profile and country-rates.
  • Calculation warnings: if you see only a warning and no numbers, send at least two monetary inputs.

#Troubleshooting & field notes

  1. Conflicting inputs: If you send net, gross and vat_amount that don’t match, the API relies on its internal math; log your raw params if you suspect rounding issues.
  2. Zero-rate logic: For vat_rate = 0 or vat_type = zero, net = gross and VAT amount = 0.
  3. Custom vs country rate: A provided vat_rate always wins over country_code/vat_type. Omit vat_rate if you want pure “country default” behaviour.
  4. Locales & separators: You can safely accept user input with , or . — normalization is handled for you.
  5. Batch use: For bulk imports, keep requests ≤ 100 rps, reuse HTTP connections, and cache stable country profiles.

#API Changelog

2025-12-10
Added advanced multi-rate mode and improved warning messages for under-specified inputs.
2025-12-01
First public v1 release of VAT API with calculate, list-countries, country-profile and country-rates actions.

الأسئلة الشائعة

يجب تقديم اثنين على الأقل من: الصافي، الإجمالي، مبلغ الضريبة أو معدل الضريبة. اختيارياً، أرسل country_code و vat_type ليختار النظام المعدل الصحيح تلقائياً.

تعمل الواجهة مع أي بلد تقوم بتكوينه في ملفات ضريبة القيمة المضافة الخاصة بك. أنت تتحكم في المعدلات المتاحة والعملة وقواعد التقريب لكل بلد.

في الوضع المتقدم (وبدون معدل ضريبة صريح)، تُرجع الواجهة سيناريوهات متعددة لجميع المعدلات المكوّنة في بلد: قياسي، مخفض، مخفض جداً وصفر.

يتبع التقريب ملف كل بلد (الدقة والوضع مثل half_up و half_even و floor وغيرها). يمكنك أيضاً تعطيل التقريب تماماً بإرسال round = false.

يستهلك كل حساب لضريبة القيمة المضافة عدداً صغيراً وثابتاً من الأرصدة لكل طلب. راجع جدول التسعير ومقدّر الأرصدة أعلاه للقيم الدقيقة.

نعم. كل طلب، حتى تلك التي تؤدي إلى أخطاء، تستهلك أرصدة. هذا لأن أرصدتك مرتبطة بعدد الطلبات، بغض النظر عن النجاح أو الفشل. إذا كان الخطأ بسبب مشكلة في المنصة من جانبنا، سنستعيد الأرصدة المتأثرة (بدون استرداد نقدي).

تواصل معنا على [email protected]. نأخذ الملاحظات بجدية—إذا كان تقرير الخطأ أو طلب الميزة ذا معنى، يمكننا إصلاح أو تحسين الواجهة بسرعة ومنحك 50 رصيدًا مجانيًا كشكر لك.

يعتمد على الواجهة وأحيانًا حتى على نقطة النهاية. بعض النقاط النهائية تستخدم بيانات من مصادر خارجية، والتي قد تكون لها حدود أكثر صرامة. نفرض أيضًا حدودًا لمنع إساءة الاستخدام والحفاظ على استقرار منصتنا. راجع الوثائق لمعرفة الحد المحدد لكل نقطة نهاية.

نعمل بنظام الأرصدة. الأرصدة هي وحدات مسبقة الدفع وغير قابلة للاسترداد تنفقها على استدعاءات API والأدوات. تُستهلك الأرصدة بنظام FIFO (الأقدم أولاً) وصالحة لمدة 12 شهرًا من تاريخ الشراء. تعرض لوحة التحكم تاريخ كل عملية شراء وانتهاء صلاحيتها.

نعم. جميع الأرصدة المشتراة (بما في ذلك الأرصدة الجزئية) صالحة لمدة 12 شهرًا من الشراء. تنتهي صلاحية الأرصدة غير المستخدمة تلقائيًا وتُحذف نهائيًا في نهاية فترة الصلاحية. لا يمكن استعادة الأرصدة المنتهية أو تحويلها إلى نقد أو قيمة أخرى. قاعدة انتقالية: الأرصدة المشتراة قبل 22 سبتمبر 2025 تُعامل كمشتراة في 22 سبتمبر 2025 وتنتهي في 22 سبتمبر 2026 (ما لم يُذكر تاريخ انتهاء أبكر عند الشراء).

نعم—ضمن فترة الصلاحية. تبقى الأرصدة غير المستخدمة متاحة وتُترحل من شهر لآخر حتى تنتهي صلاحيتها بعد 12 شهرًا من الشراء.

الأرصدة غير قابلة للاسترداد. اشترِ فقط ما تحتاجه—يمكنك دائمًا إعادة الشحن لاحقًا. إذا تسبب خطأ في المنصة في فشل الشحن، قد نستعيد الأرصدة المتأثرة بعد التحقيق. لا استرداد نقدي.

الأسعار محددة بالأرصدة وليس بالدولارات. كل نقطة نهاية لها تكلفتها الخاصة—انظر شارة "الأرصدة / الطلب" أعلاه. ستعرف دائمًا بالضبط ما تنفقه.
← العودة إلى واجهات البرمجة