Paste API Dokumentasyonu

Paste servisini programatik olarak kullanmak için RESTful API

Base URL: https://paste.yakupkaya.me/api/
Programlama Dili

Başlangıç

Paste API'sini kullanarak programatik olarak paste'ler oluşturabilir, görüntüleyebilir ve yönetebilirsiniz.

Temel Özellikler:
  • Metin ve resim paste'leri oluşturma
  • Mevcut paste'leri görüntüleme
  • Rate limiting koruması
  • API key ile kimlik doğrulama (isteğe bağlı)
  • JSON yanıtlar

Kimlik Doğrulama

Bazı endpoint'ler API key gerektirir. API key'inizi buradan alabilirsiniz.

API key'inizi HTTP header'ında gönderin:

Authorization: Bearer YOUR_API_KEY

Veya POST parametresi olarak gönderin:

{"api_key": "YOUR_API_KEY"}

Rate Limiting

API kullanımı rate limiting ile korunur:

  • Metin Paste: 100 istek/saat
  • Resim Paste: 50 istek/saat

Rate limit bilgilerinizi /api/rate-limit/status/ endpoint'inden kontrol edebilirsiniz.

Paste Operations

POST /api/paste/text/
Create Text Paste

Create a new text paste

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
content string - Paste content
title string - - Paste title
language string - txt Programming language
is_public boolean - - Public visibility
Yanıt Örneği:
{
  "success": true,
  "paste_id": "abc123",
  "url": "/paste/abc123/",
  "raw_url": "/paste/abc123/raw/",
  "created_at": "2025-09-13T17:30:00Z"
}
Kod Örnekleri:
curl -X POST https://paste.yakupkaya.me/api/paste/text/ \
  -H "Content-Type: application/json" \
  -d '{"content": "Hello World", "title": "Test Paste", "language": "txt"}'
POST /api/paste/image/
Create Image Paste

Upload an image paste

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
image file - Image file to upload
title string - - Paste title
is_public boolean - - Public visibility
Yanıt Örneği:
{
  "success": true,
  "paste_id": "xyz789",
  "url": "/paste/xyz789/",
  "image_url": "/media/paste/image.jpg",
  "created_at": "2025-09-13T17:30:00Z"
}
Kod Örnekleri:
curl -X POST https://paste.yakupkaya.me/api/paste/image/ \
  -H "Content-Type: application/json" \
  -d '{"content": "Hello World", "title": "Test Paste", "language": "txt"}'
GET /api/paste/{paste_id}/
Get Paste Details

Retrieve paste information and content

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
paste_id string - Paste ID
Yanıt Örneği:
{
  "success": true,
  "paste_id": "abc123",
  "title": "My Paste",
  "content": "Hello World",
  "language": "txt",
  "paste_type": "text",
  "is_public": false,
  "created_at": "2025-09-13T17:30:00Z",
  "views": 5
}
Kod Örnekleri:
curl -X GET https://paste.yakupkaya.me/api/paste/{paste_id}/
GET /api/paste/{paste_id}/raw/
Get Raw Paste Content

Get raw paste content as plain text

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
paste_id string - Paste ID
Yanıt Örneği:
Raw paste content as plain text
Kod Örnekleri:
curl -X GET https://paste.yakupkaya.me/api/paste/{paste_id}/raw/
DELETE /api/paste/{paste_id}/delete/ 🔐 API Key Gerekli
Delete Paste

Delete a paste (requires API key)

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
paste_id string - Paste ID
api_key string - API Key
Yanıt Örneği:
{
  "success": true,
  "message": "Paste deleted successfully"
}
Kod Örnekleri:
curl -X DELETE https://paste.yakupkaya.me/api/paste/{paste_id}/delete/

Statistics

GET /api/stats/
General Statistics

Get general paste statistics

Yanıt Örneği:
{
  "total_pastes": 1234,
  "text_pastes": 1000,
  "image_pastes": 234,
  "public_pastes": 800,
  "total_views": 5000
}
Kod Örnekleri:
curl -X GET https://paste.yakupkaya.me/api/stats/
GET /api/user-stats/ 🔐 API Key Gerekli
User Statistics

Get user-specific statistics (requires API key)

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
api_key string - API Key
Yanıt Örneği:
{
  "user": "username",
  "total_pastes": 50,
  "text_pastes": 40,
  "image_pastes": 10,
  "total_views": 500
}
Kod Örnekleri:
curl -X GET https://paste.yakupkaya.me/api/user-stats/

Authentication

POST /api/validate-key/ 🔐 API Key Gerekli
Validate API Key

Validate an API key

Parametreler:
Parametre Tip Gerekli Varsayılan Açıklama
api_key string - API Key to validate
Yanıt Örneği:
{
  "valid": true,
  "user": "username",
  "created_at": "2025-09-01T00:00:00Z"
}
Kod Örnekleri:
curl -X POST https://paste.yakupkaya.me/api/validate-key/ \
  -H "Content-Type: application/json" \
  -d '{"content": "Hello World", "title": "Test Paste", "language": "txt"}'

Rate Limiting

GET /api/rate-limit/status/
Rate Limit Status

Check current rate limit status

Yanıt Örneği:
{
  "api_text": {
    "limit": 100,
    "remaining": 95,
    "reset_time": "2025-09-13T18:00:00Z"
  },
  "api_image": {
    "limit": 50,
    "remaining": 45,
    "reset_time": "2025-09-13T18:00:00Z"
  }
}
Kod Örnekleri:
curl -X GET https://paste.yakupkaya.me/api/rate-limit/status/

Pratik Örnekler

Basit Metin Paste (cURL)
curl -X POST https://paste.yakupkaya.me/api/paste/text/ \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hello, World!",
    "title": "My First Paste",
    "language": "txt",
    "is_public": true
  }'
Python ile Paste Oluşturma
import requests

data = {
    'content': 'print("Hello, World!")',
    'title': 'Python Example',
    'language': 'python',
    'is_public': False
}

response = requests.post('https://paste.yakupkaya.me/api/paste/text/', json=data)
result = response.json()

if result['success']:
    print(f"Paste created: {result['url']}")
else:
    print(f"Error: {result.get('error', 'Unknown error')}")
JavaScript ile Paste Görüntüleme
async function getPaste(pasteId) {
    try {
        const response = await fetch(`https://paste.yakupkaya.me/api/paste/${pasteId}/`);
        const data = await response.json();
        
        if (data.success) {
            console.log('Title:', data.title);
            console.log('Content:', data.content);
            console.log('Language:', data.language);
        } else {
            console.error('Error:', data.error);
        }
    } catch (error) {
        console.error('Network error:', error);
    }
}

getPaste('abc123');
Go ile API İstatistikleri
package main

import (
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

type Stats struct {
    TotalPastes int `json:"total_pastes"`
    TextPastes  int `json:"text_pastes"`
    ImagePastes int `json:"image_pastes"`
    TotalViews  int `json:"total_views"`
}

func main() {
    resp, err := http.Get("https://paste.yakupkaya.me/api/stats/")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    
    var stats Stats
    json.Unmarshal(body, &stats)
    
    fmt.Printf("Total Pastes: %d\n", stats.TotalPastes)
    fmt.Printf("Text Pastes: %d\n", stats.TextPastes)
    fmt.Printf("Image Pastes: %d\n", stats.ImagePastes)
}
Java ile Resim Yükleme
import java.io.*;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Paths;

public class ImageUpload {
    public static void main(String[] args) throws IOException {
        String boundary = "----WebKitFormBoundary" + System.currentTimeMillis();
        
        URL url = new URL("https://paste.yakupkaya.me/api/paste/image/");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
        
        try (OutputStream os = conn.getOutputStream();
             PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF-8"))) {
            
            // Add title field
            writer.append("--" + boundary).append("\r\n");
            writer.append("Content-Disposition: form-data; name=\"title\"").append("\r\n");
            writer.append("\r\n").append("My Image").append("\r\n");
            
            // Add image file
            writer.append("--" + boundary).append("\r\n");
            writer.append("Content-Disposition: form-data; name=\"image\"; filename=\"image.jpg\"").append("\r\n");
            writer.append("Content-Type: image/jpeg").append("\r\n");
            writer.append("\r\n").flush();
            
            Files.copy(Paths.get("path/to/your/image.jpg"), os);
            os.flush();
            
            writer.append("\r\n").flush();
            writer.append("--" + boundary + "--").append("\r\n").flush();
        }
        
        // Read response
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();
        
        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();
        
        System.out.println(response.toString());
    }
}
Ruby ile Paste Silme
require 'net/http'
require 'json'

def delete_paste(paste_id, api_key)
  uri = URI("https://paste.yakupkaya.me/api/paste/#{paste_id}/delete/")
  
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true if uri.scheme == 'https'
  
  request = Net::HTTP::Delete.new(uri)
  request['Content-Type'] = 'application/json'
  request.body = { api_key: api_key }.to_json
  
  response = http.request(request)
  result = JSON.parse(response.body)
  
  if result['success']
    puts "Paste deleted successfully"
  else
    puts "Error: #{result['error']}"
  end
end

# Usage
delete_paste('abc123', 'your-api-key-here')

Hata Kodları

HTTP Kodu Hata Kodu Açıklama
400 CONTENT_REQUIRED İçerik parametresi gerekli
401 UNAUTHORIZED Geçersiz veya eksik API key
404 PASTE_NOT_FOUND Paste bulunamadı
413 CONTENT_TOO_LARGE İçerik çok büyük
429 RATE_LIMIT_EXCEEDED Rate limit aşıldı