API Referansı
Genel Bakış
MD5 hash hesaplayıcısı, metin hesaplama, dosya işleme ve toplu işlemleri destekleyen tam bir RESTful API arayüzü sağlar.
Temel Bilgiler
- Temel URL:
https://api.example.com/md5
- Kimlik Doğrulama: API Anahtarı
- Veri Formatı: JSON
- Karakter Kodlaması: UTF-8
Yanıt Formatı
Tüm API yanıtları birleşik bir formatı takip eder:
{
"success": true,
"data": {
// Belirli veriler
},
"message": "İşlem başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Metin MD5 Hesaplama
Metin MD5 Hesaplama
Uç Nokta: POST /api/md5/text
İstek Parametreleri:
{
"text": "Hesaplanacak metin içeriği",
"encoding": "utf8",
"outputFormat": "hex"
}
Parametre Açıklaması:
Parametre | Tip | Gerekli | Açıklama |
---|---|---|---|
text | string | Evet | Hesaplanacak metin içeriği MD5 |
encoding | string | Hayır | Karakter kodlaması, varsayılan utf8 |
outputFormat | string | Hayır | Çıktı formatı, varsayılan hex |
Desteklenen Kodlama Formatları:
utf8
: UTF-8 kodlamasıascii
: ASCII kodlamasıutf16
: UTF-16 kodlamasıgbk
: GBK kodlaması
Desteklenen Çıktı Formatları:
hex
: Küçük harf onaltılıkhex-upper
: Büyük harf onaltılıkbase64
: Base64 kodlaması
Yanıt Örneği:
{
"success": true,
"data": {
"text": "Hello, World!",
"hash": "65a8e27d8879283831b664bd8b7f0ad4",
"encoding": "utf8",
"outputFormat": "hex",
"length": 32
},
"message": "Hesaplama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Toplu Metin Hesaplama
Uç Nokta: POST /api/md5/text/batch
İstek Parametreleri:
{
"texts": ["Metin1", "Metin2", "Metin3"],
"encoding": "utf8",
"outputFormat": "hex"
}
Yanıt Örneği:
{
"success": true,
"data": {
"results": [
{
"text": "Metin1",
"hash": "hash1",
"index": 0
},
{
"text": "Metin2",
"hash": "hash2",
"index": 1
},
{
"text": "Metin3",
"hash": "hash3",
"index": 2
}
],
"total": 3,
"encoding": "utf8",
"outputFormat": "hex"
},
"message": "Toplu hesaplama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Dosya MD5 Hesaplama
Yüklenen Dosya Hesaplama
Uç Nokta: POST /api/md5/file
İstek Formatı: multipart/form-data
İstek Parametreleri:
Parametre | Tip | Gerekli | Açıklama |
---|---|---|---|
file | file | Evet | Hesaplanacak dosya |
outputFormat | string | Hayır | Çıktı formatı, varsayılan hex |
Yanıt Örneği:
{
"success": true,
"data": {
"filename": "example.txt",
"size": 1024,
"hash": "d41d8cd98f00b204e9800998ecf8427e",
"outputFormat": "hex",
"processingTime": 150
},
"message": "Dosya hesaplama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Toplu Dosya Hesaplama
Uç Nokta: POST /api/md5/file/batch
İstek Formatı: multipart/form-data
İstek Parametreleri:
Parametre | Tip | Gerekli | Açıklama |
---|---|---|---|
files | file | Evet | Hesaplanacak dosyalar dizisi |
outputFormat | string | Hayır | Çıktı formatı, varsayılan hex |
Yanıt Örneği:
{
"success": true,
"data": {
"results": [
{
"filename": "file1.txt",
"size": 1024,
"hash": "hash1",
"processingTime": 150
},
{
"filename": "file2.txt",
"size": 2048,
"hash": "hash2",
"processingTime": 200
}
],
"total": 2,
"totalSize": 3072,
"totalTime": 350
},
"message": "Toplu dosya hesaplama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Hash Değeri Doğrulama
Hash Değeri Doğrulama
Uç Nokta: POST /api/md5/verify
İstek Parametreleri:
{
"text": "Doğrulanacak metin",
"expectedHash": "Beklenen hash değeri",
"encoding": "utf8"
}
Yanıt Örneği:
{
"success": true,
"data": {
"text": "Hello, World!",
"expectedHash": "65a8e27d8879283831b664bd8b7f0ad4",
"calculatedHash": "65a8e27d8879283831b664bd8b7f0ad4",
"isValid": true,
"encoding": "utf8"
},
"message": "Doğrulama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Dosya Bütünlüğü Doğrulama
Uç Nokta: POST /api/md5/verify/file
İstek Formatı: multipart/form-data
İstek Parametreleri:
Parametre | Tip | Gerekli | Açıklama |
---|---|---|---|
file | file | Evet | Doğrulanacak dosya |
expectedHash | string | Evet | Beklenen hash değeri |
Yanıt Örneği:
{
"success": true,
"data": {
"filename": "example.txt",
"expectedHash": "d41d8cd98f00b204e9800998ecf8427e",
"calculatedHash": "d41d8cd98f00b204e9800998ecf8427e",
"isValid": true,
"size": 1024
},
"message": "Dosya bütünlüğü doğrulama başarılı",
"timestamp": "2024-01-20T10:30:00Z"
}
Hata Yönetimi
Hata Yanıt Formatı
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Hata açıklaması",
"details": "Detaylı hata bilgisi"
},
"timestamp": "2024-01-20T10:30:00Z"
}
Yaygın Hata Kodları
Hata Kodu | Açıklama | HTTP Durum Kodu |
---|---|---|
INVALID_INPUT | Geçersiz giriş parametreleri | 400 |
FILE_TOO_LARGE | Dosya çok büyük | 413 |
UNSUPPORTED_ENCODING | Desteklenmeyen kodlama formatı | 400 |
INVALID_HASH_FORMAT | Geçersiz hash formatı | 400 |
RATE_LIMIT_EXCEEDED | İstek sıklığı sınırı aşıldı | 429 |
INTERNAL_ERROR | Sunucu iç hatası | 500 |
Kullanım Örnekleri
JavaScript Örneği
// Metin MD5 hesaplama
const calculateTextMD5 = async (text) => {
const response = await fetch('/api/md5/text', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer YOUR_API_KEY',
},
body: JSON.stringify({
text,
encoding: 'utf8',
outputFormat: 'hex',
}),
});
const result = await response.json();
return result.data.hash;
};
// Dosya MD5 hesaplama
const calculateFileMD5 = async (file) => {
const formData = new FormData();
formData.append('file', file);
const response = await fetch('/api/md5/file', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
body: formData,
});
const result = await response.json();
return result.data.hash;
};
// Hash değeri doğrulama
const verifyHash = async (text, expectedHash) => {
const response = await fetch('/api/md5/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer YOUR_API_KEY',
},
body: JSON.stringify({
text,
expectedHash,
encoding: 'utf8',
}),
});
const result = await response.json();
return result.data.isValid;
};
Python Örneği
import requests
import json
# Metin MD5 hesaplama
def calculate_text_md5(text, api_key):
url = "https://api.example.com/md5/text"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
data = {
"text": text,
"encoding": "utf8",
"outputFormat": "hex"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
if result["success"]:
return result["data"]["hash"]
else:
raise Exception(result["error"]["message"])
# Dosya MD5 hesaplama
def calculate_file_md5(file_path, api_key):
url = "https://api.example.com/md5/file"
headers = {
"Authorization": f"Bearer {api_key}"
}
with open(file_path, 'rb') as file:
files = {'file': file}
response = requests.post(url, headers=headers, files=files)
result = response.json()
if result["success"]:
return result["data"]["hash"]
else:
raise Exception(result["error"]["message"])
# Hash değeri doğrulama
def verify_hash(text, expected_hash, api_key):
url = "https://api.example.com/md5/verify"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
data = {
"text": text,
"expectedHash": expected_hash,
"encoding": "utf8"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
if result["success"]:
return result["data"]["isValid"]
else:
raise Exception(result["error"]["message"])
cURL Örneği
# Metin MD5 hesaplama
curl -X POST "https://api.example.com/md5/text" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "Hello, World!",
"encoding": "utf8",
"outputFormat": "hex"
}'
# Dosya MD5 hesaplama
curl -X POST "https://api.example.com/md5/file" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@example.txt"
# Hash değeri doğrulama
curl -X POST "https://api.example.com/md5/verify" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "Hello, World!",
"expectedHash": "65a8e27d8879283831b664bd8b7f0ad4",
"encoding": "utf8"
}'
Sınırlamalar
İstek Sınırlamaları
- Metin uzunluğu: Maksimum 10MB
- Dosya boyutu: Maksimum 100MB
- Toplu miktar: Maksimum 100 öğe
- İstek sıklığı: Dakikada maksimum 1000 istek
Desteklenen Formatlar
- Metin kodlaması: UTF-8, ASCII, UTF-16, GBK
- Çıktı formatı: Onaltılık (büyük/küçük harf), Base64
- Dosya türleri: Tüm dosya türleri
Son Güncelleme: 20 Ocak 2024