StarkCDN REST API
Herhangi bir uygulamadan gorsel yukleyin, listeleyin, boyutlandirin ve silin. Cloudinary-benzeri basit bir REST API.
Temel URL
https://cdn.starkbilisim.com/api/api.php
Tum endpointler bu URL uzerinden ?action= parametresi ile erisilir.
AUTH Kimlik Dogrulama
API'ye erismek icin iki yontem mevcuttur. Her iki yontem de butun endpointlerde calisir.
JWT Token (Web Panel)
Web panelinden giris yaptiginizda alinan token ile Authorization header'i kullanin.
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
API Anahtari (Uygulamalar)
API anahtarinizi kontrol panelinden alin. 3 farkli sekilde gonderebilirsiniz:
X-API-Key: API_ANAHTARINIZ
?api_key=API_ANAHTARINIZ
api_key=API_ANAHTARINIZ
Rate Limitler
| Islem | Limit | Pencere |
|---|---|---|
| Giris | 10 deneme | 5 dakika |
| Kayit | 3 deneme | 1 saat |
| API istekleri | Limitsiz* | - |
* Sunucu kaynaklarina bagli olarak adil kullanim politikalari uygulanabilir.
POST Gorsel Yukle
?action=upload
Parametreler (multipart/form-data)
| Parametre | Tip | Aciklama |
|---|---|---|
project_id | int | Hedef proje ID (zorunlu) |
image | file | Gorsel dosyasi (zorunlu) |
width | int | Hedef genislik (opsiyonel) |
height | int | Hedef yukseklik (opsiyonel) |
fit | string | cover (varsayilan) veya contain |
$ch = curl_init('https://cdn.starkbilisim.com/api/api.php?action=upload');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: API_ANAHTARINIZ']);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'project_id' => '1',
'image' => new CURLFile('/dosya/yolu/gorsel.jpg')
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo $data['image']['url'];
const formData = new FormData();
formData.append('project_id', '1');
formData.append('image', fileInput.files[0]);
const res = await fetch('https://cdn.starkbilisim.com/api/api.php?action=upload', {
method: 'POST',
headers: { 'X-API-Key': 'API_ANAHTARINIZ' },
body: formData
});
const data = await res.json();
console.log(data.image.url);
import requests
response = requests.post(
'https://cdn.starkbilisim.com/api/api.php?action=upload',
headers={'X-API-Key': 'API_ANAHTARINIZ'},
files={'image': open('foto.jpg', 'rb')},
data={'project_id': '1'}
)
data = response.json()
print(data['image']['url'])
curl -X POST "https://cdn.starkbilisim.com/api/api.php?action=upload" \
-H "X-API-Key: API_ANAHTARINIZ" \
-F "project_id=1" \
-F "image=@foto.jpg"
{
"success": true,
"image": {
"id": 42,
"project_id": 1,
"original_name": "foto.jpg",
"url": "https://cdn.starkbilisim.com/uploads/user_1/project_7/abc123.jpg",
"file_size": 245760,
"mime_type": "image/jpeg",
"width": 1920,
"height": 1080,
"created_at": "2026-04-09 12:30:00"
}
}
POST URL'den Yukle
?action=url_upload
Parametreler (JSON body)
| Parametre | Tip | Aciklama |
|---|---|---|
url | string | Herkese acik gorsel URL'si (zorunlu) |
project_id | int | Hedef proje ID (zorunlu) |
width | int | Hedef genislik (opsiyonel) |
height | int | Hedef yukseklik (opsiyonel) |
fit | string | cover veya contain |
const res = await fetch('https://cdn.starkbilisim.com/api/api.php?action=url_upload', {
method: 'POST',
headers: {
'X-API-Key': 'API_ANAHTARINIZ',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://ornek.com/foto.jpg',
project_id: 1,
width: 800,
fit: 'cover'
})
});
const data = await res.json();
console.log(data.image.url);
response = requests.post(
'https://cdn.starkbilisim.com/api/api.php?action=url_upload',
headers={'X-API-Key': 'API_ANAHTARINIZ'},
json={
'url': 'https://ornek.com/foto.jpg',
'project_id': 1
}
)
print(response.json()['image']['url'])
curl -X POST "https://cdn.starkbilisim.com/api/api.php?action=url_upload" \
-H "X-API-Key: API_ANAHTARINIZ" \
-H "Content-Type: application/json" \
-d '{"url":"https://ornek.com/foto.jpg","project_id":1}'
{
"success": true,
"image": {
"id": 5,
"project_id": 1,
"original_name": "foto.jpg",
"url": "https://cdn.starkbilisim.com/uploads/user_1/project_1/abc.jpg",
"source_url": "https://ornek.com/foto.jpg",
"file_size": 153600,
"mime_type": "image/jpeg",
"width": 800,
"height": 600,
"created_at": "2026-04-09 12:30:00"
}
}
GET Gorselleri Listele
?action=list&project_id=1
Parametreler
| Parametre | Tip | Aciklama |
|---|---|---|
project_id | int | Proje ID (zorunlu) |
page | int | Sayfa numarasi (varsayilan: 1) |
limit | int | Sayfa basina gorsel (max 100, varsayilan: 50) |
sort | string | newest | oldest | name_asc | name_desc |
// JavaScript
const res = await fetch(
'https://cdn.starkbilisim.com/api/api.php?action=list&project_id=1&page=1&limit=20&sort=newest',
{ headers: { 'X-API-Key': 'API_ANAHTARINIZ' } }
);
const data = await res.json();
// data.images - Gorsel dizisi
// data.total - Toplam gorsel sayisi
// data.page - Mevcut sayfa
// data.totalPages - Toplam sayfa
{
"images": [
{
"id": 42,
"original_name": "foto.jpg",
"url": "https://cdn.starkbilisim.com/uploads/user_1/project_7/abc123.jpg",
"file_size": 245760,
"mime_type": "image/jpeg",
"width": 1920,
"height": 1080,
"created_at": "2026-04-09 12:30:00"
}
],
"total": 1,
"page": 1,
"totalPages": 1
}
DELETE Gorsel Sil
?action=delete&id=42
Parametreler
| Parametre | Tip | Aciklama |
|---|---|---|
id | int | Silinecek gorsel ID (zorunlu) |
// JavaScript
const res = await fetch(
'https://cdn.starkbilisim.com/api/api.php?action=delete&id=42',
{ method: 'DELETE', headers: { 'X-API-Key': 'API_ANAHTARINIZ' } }
);
// { "success": true, "message": "Image deleted" }
// cURL
// curl -X DELETE "https://cdn.starkbilisim.com/api/api.php?action=delete&id=42" \
// -H "X-API-Key: API_ANAHTARINIZ"
GET Projeleri Listele
?action=projects
Parametre gerektirmez. Kullanicinin tum projelerini dondurur.
{
"projects": [
{
"id": 1,
"name": "Blog Gorselleri",
"description": "Web sitem icin gorseller",
"image_count": 15,
"created_at": "2026-03-15 10:00:00"
},
{
"id": 2,
"name": "Urun Fotograflari",
"description": "E-ticaret urun gorselleri",
"image_count": 42,
"created_at": "2026-04-01 14:30:00"
}
]
}
GET Istatistikler
?action=stats
Kullanicinin genel istatistiklerini, son yuklenen gorselleri ve aylik yukleme grafigini dondurur.
{
"projects": 5,
"images": 127,
"storage_bytes": 52428800,
"storage_formatted": "50.0 MB",
"recent_images": [...],
"monthly_uploads": [
{ "month": "2026-03", "count": 45 },
{ "month": "2026-04", "count": 82 }
]
}
GET Gorsel Sunumu / Dinamik Boyutlandirma
?action=serve&id=42&w=300&h=200&fit=cover
Mevcut bir gorseli istenen boyutta sunar. Boyutlandirilmis surumler otomatik olarak onbellekte tutulur (disk cache).
Parametreler
| Parametre | Tip | Aciklama |
|---|---|---|
id | int | Gorsel ID (zorunlu) |
w | int | Genislik (piksel, opsiyonel) |
h | int | Yukseklik (piksel, opsiyonel) |
fit | string | cover (kirpma, varsayilan) veya contain (sigdir) |
<img src="https://cdn.starkbilisim.com/api/api.php?action=serve&id=42&w=300&fit=cover&api_key=API_ANAHTARINIZ"
alt="Thumbnail"
width="300">
<picture>
<source media="(min-width: 768px)"
srcset="https://cdn.starkbilisim.com/api/api.php?action=serve&id=42&w=800&fit=cover&api_key=KEY">
<img src="https://cdn.starkbilisim.com/api/api.php?action=serve&id=42&w=400&fit=cover&api_key=KEY"
alt="Responsive gorsel">
</picture>
- w/h belirtmezseniz orijinal gorsel dondurulur
- Sadece w veya h belirtirseniz, diger boyut en-boy oranina gore hesaplanir
- Orijinalden daha buyuk boyut isterseniz orijinal gorsel dondurulur (buyutme yapilmaz)
- Boyutlandirilmis gorseller diskte onbellege alinir, sonraki istekler anlik donulur
Hata Kodlari
| Kod | Anlami | Aciklama |
|---|---|---|
400 | Bad Request | Eksik veya gecersiz parametre |
401 | Unauthorized | Gecersiz veya eksik API anahtari/token |
403 | Forbidden | Hesap bloke edilmis |
404 | Not Found | Gorsel veya proje bulunamadi |
405 | Method Not Allowed | Yanlis HTTP metodu (orn: GET yerine POST) |
409 | Conflict | E-posta zaten kayitli |
429 | Too Many Requests | Rate limit asildi |
{ "error": "Invalid API key format" }
Dosya Limitleri
| Ozellik | Deger |
|---|---|
| Maks dosya boyutu | 5 MB |
| Maks gorsel boyutu | 8000 x 8000 piksel |
| Maks boyutlandirma | 4000 piksel |
| Desteklenen formatlar | JPG, PNG, GIF, WebP |
| Onbellek suresi | 24 saat (Cache-Control header) |