İndirim Hesabı
Finans Hesaplama Kredi / istek: 1Liste fiyatına yüzde veya tutar indirimi uygular.
GET
https://api.apikodu.com/api/v1/math/discount
Dokümantasyon
Genel bakış
İndirim hesaplar (yüzde veya sabit tutar).
Kimlik doğrulama
Her istekte x-api-key başlığı zorunludur. Kullanılan kredi ve kalan kota yanıt başlıklarında (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*) döner.
İstek
GET
https://api.apikodu.com/api/v1/math/discount?amount=100&mode=percent&rate=10¤cy=EUR
GET query veya POST JSON (tek tutar veya dizi).
Parametreler
| Ad | Tip | Zorunlu | Varsayılan | Seçenekler | Açıklama |
|---|---|---|---|---|---|
amount |
number | * Zorunlu | — | — | Liste fiyatı (GET). POST'ta amount veya items. |
mode |
string | Opsiyonel | percent |
percent fixed |
percent veya fixed. |
rate |
number | Opsiyonel | — | — | percent mode oranı. |
amountDiscount |
number | Opsiyonel | — | — | fixed mode indirim tutarı. |
currency |
string | Opsiyonel | — | — | ISO kod. |
Yanıt
| Ad | Tip | Açıklama |
|---|---|---|
amountList |
number | İndirim öncesi liste fiyatı. 2 ondalık. |
amountDiscount |
number | Toplam indirim tutarı. Birden fazla adım varsa toplamı. |
amountNet |
number | İndirim sonrası ödenecek tutar. |
savingPercent |
number | Tasarruf yüzdesi = amountDiscount / amountList * 100. |
currency |
string | ISO para kodu. Gönderilmediyse null. |
breakdown |
array | Uygulanan her indirim adımı. GET'te tek adım. |
breakdown[].index |
integer | Adım sıra no (1'den). |
breakdown[].mode |
string | Adım modu: percent veya fixed. |
breakdown[].amountBefore |
number | Bu adım öncesi tutar. |
breakdown[].amountDiscount |
number | Bu adımın indirdiği tutar. |
breakdown[].amountAfter |
number | Bu adım sonrası tutar. |
Hatalar
| HTTP | code | Açıklama |
|---|---|---|
400 |
-241 |
amount yok/aralık dışı, POST gövde yok, veya fixed modda amountDiscount negatif. |
400 |
-242 |
mode percent veya fixed değil. |
401 |
-100 |
x-api-key yok, boş, prefix/uzunluk hatalı, pasif, yasaklı, süresi dolmuş, IP kısıtına takıldı veya bu API anahtara izinli değil. |
429 |
-221 |
Dakikalık istek limiti aşıldı. Yanıt başlıkları: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset. |
429 |
— | Paket kredi kotası bu isteğin kredisini karşılamıyor. Gövde { error, limit, currentUsage, requestCost } olabilir (code alanı yok). |
500 |
-1 |
Beklenmeyen sunucu hatası. message genel bir hata metnidir; teknik ayrıntı içermez. |
Notlar
- Başarılı gövde { data: { ... } } şeklindedir. Hata gövdesi { code, message } şeklindedir. code alanı ApiResponseCode enum değeridir (negatif tam sayı).
- POST /discount gövde ile aynı alanları kabul eder.
Örnek yanıt
{
"data": {
"amountList": 100.00,
"amountDiscount": 10.00,
"amountNet": 90.00,
"savingPercent": 10.0,
"currency": "EUR",
"breakdown": [
{
"index": 1,
"mode": "percent",
"amountBefore": 100.00,
"amountDiscount": 10.00,
"amountAfter": 90.00
}
]
}
}
Kod örnekleri
const response = await fetch('https://api.apikodu.com/api/v1/math/discount', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
import requests
headers = {
'x-api-key': 'YOUR_API_KEY'
}
response = requests.get('https://api.apikodu.com/api/v1/math/discount', headers=headers)
print(response.json())
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");
var response = await client.GetStringAsync("https://api.apikodu.com/api/v1/math/discount");
Console.WriteLine(response);
$response = file_get_contents('https://api.apikodu.com/api/v1/math/discount', false, stream_context_create([
'http' => [
'header' => "x-api-key: YOUR_API_KEY"
]
]));
print_r(json_decode($response, true));
curl -X GET 'https://api.apikodu.com/api/v1/math/discount' \
-H 'x-api-key: YOUR_API_KEY'
Hemen denemeye başlayın
Ücretsiz hesap açın, API anahtarınızı alın ve ilk isteğinizi dakikalar içinde gönderin.