Anasayfa Web Geliştirme ve Programlama API Geliştirme 2026: RESTful, GraphQL ve Entegrasyonlarla Modern Web Projeleri Kurma Rehberi

API Geliştirme 2026: RESTful, GraphQL ve Entegrasyonlarla Modern Web Projeleri Kurma Rehberi

Son güncelleme tarihi Feb 18, 2026

Giriş: API Nedir ve Neden 2026'da Vazgeçilmez Hale Geldi?

API (Application Programming Interface), yazılımlar arası iletişim köprüsüdür. 2026 yılında API'ler artık sadece "bağlantı aracı" değil; mikro servis mimarilerinin kalbi, mobil/web uygulamaların beyni ve üçüncü parti entegrasyonların (ödeme gateway'leri, AI servisleri, CRM'ler) zorunlu unsuru haline geldi.

Neden vazgeçilmez?

  • Mikro servisler ve decoupled mimarilerde her servis kendi API'sini sunar.

  • Frontend (Next.js, React Native) ve backend (Node, Python) arasında veri akışı sağlar.

  • Üçüncü parti servis entegrasyonu: Stripe, OpenAI, Google Maps, Twilio gibi araçlar olmadan modern uygulama düşünülemez.

  • API ekonomisi büyüyor: Gartner tahminlerine göre 2027'ye kadar GraphQL kullanan şirketler %60'ı aşacak; gRPC iç mikro servislerde dominant.

  • AI ajanları ve agentic sistemler API'leri tüketiyor – 2026'da API talebinin %30+ artışı AI kaynaklı.

Kaliteweb olarak bu rehberde RESTful temellerden GraphQL'e, güvenlikten hosting'e kadar 2026 güncel pratikleri adım adım anlatıyoruz.

RESTful API Temelleri

REST (Representational State Transfer), en yaygın API tarzı. 2026'da hâlâ public/external API'lerin %70+ giriş noktası.

Ana Unsurlar:

  • HTTP Yöntemleri: GET (okuma), POST (oluşturma), PUT/PATCH (güncelleme), DELETE (silme).

  • Status Kodları: 200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Too Many Requests, 500 Internal Server Error.

  • JSON Standartları: Her zaman application/json; camelCase veya snake_case tutarlılığı, HATEOAS (opsiyonel).

  • Authentication Yöntemleri:

    • API Key: Basit, header'da X-API-Key: abc123.

    • JWT (JSON Web Token): Stateless, Bearer token ile. Expiration + refresh token zorunlu.

    • OAuth 2.0: Üçüncü parti (Google, GitHub login) için. Authorization Code + PKCE mobil için standart.

Adım Adım REST API Oluşturma Örneği (FastAPI ile – 2026 Tavsiyesi)

Python + FastAPI, 2026'da en hızlı geliştirilen REST framework'lerden (type hints + otomatik docs).

  1. Kurulum:

    
    pip install fastapi uvicorn pydantic[email]
    
    
  2. main.py (basit CRUD):

    
    from fastapi import FastAPI, HTTPException, Depends, status
    from pydantic import BaseModel
    from typing import List
    from fastapi.security import OAuth2PasswordBearer
    app = FastAPI(title="Kaliteweb Todo API 2026")
    
    class Todo(BaseModel):
        id: int
        title: str
        completed: bool = False
    
    todos: List[Todo] = []
    
    oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")  # JWT simülasyonu
    
    @app.get("/todos/", response_model=List[Todo])
    
    async def get_todos(token: str = Depends(oauth2_scheme)):
        return todos
    
    @app.post("/todos/", response_model=Todo, status_code=201)
    
    async def create_todo(todo: Todo):
        if any(t.id == todo.id for t in todos):
            raise HTTPException(status_code=400, detail="ID zaten var")
        todos.append(todo)
        return todo
    
    @app.put("/todos/{todo_id}", response_model=Todo)
    
    async def update_todo(todo_id: int, updated: Todo):
        for i, t in enumerate(todos):
            if t.id == todo_id:
                todos[i] = updated
                return updated
        raise HTTPException(status_code=404, detail="Todo bulunamadı")
    
    
  3. Çalıştırma: uvicorn main:app --reload

  4. Test: Postman veya Swagger (/docs otomatik gelir).

Pratik Checklist – REST API Başarısı İçin:

  • Her endpoint'e rate limiting ekleyin (slowapi).

  • Input validation: Pydantic + custom validators.

  • Error handling: Global exception handler.

  • CORS: Doğru origin'leri whitelist'e alın.

  • Logging: Structured JSON log (Loguru veya structlog).

GraphQL Nedir ve Avantajları

GraphQL, client'ın tam istediği veriyi sorgulamasını sağlar. Facebook tarafından geliştirildi, 2026'da client-facing API'lerde standart.

Avantajlar:

  • Over/under-fetching yok.

  • Tek istekte birden fazla resource.

  • Strong typing + introspection.

  • Subscriptions (real-time) kolay.

GraphQL Proje Örneği (Next.js + Apollo):

Backend (Apollo Server):


const { ApolloServer } = require('apollo-server');

const typeDefs = `
  type Todo { id: ID!, title: String!, completed: Boolean! }
  type Query { todos: [Todo!]! }
  type Mutation { addTodo(title: String!): Todo! }
`;

const resolvers = { ... };

const server = new ApolloServer({ typeDefs, resolvers });

server.listen().then(({ url }) => console.log(url));

Frontend (Next.js App Router):


import { ApolloClient, InMemoryCache, gql } from '@apollo/client';

const client = new ApolloClient({
  uri: 'http://localhost:4000',
  cache: new InMemoryCache()
});

async function getTodos() {
  const { data } = await client.query({
    query: gql`query { todos { id title completed } }`
  });
  return data.todos;
}

Popüler Araçlar ve Servisler

  • Docs: Swagger/OpenAPI (REST), GraphQL Playground / Apollo Studio.

  • Rate Limiting & Caching: Redis + express-rate-limit, Apollo Data Sources.

  • Monitoring: Prometheus + Grafana, Datadog API monitoring.

Güvenlik Konuları: OWASP API Security Top 10 (2023-2026 Güncel)

OWASP API Security Top 10 (2023 versiyonu hâlâ referans, 2026'da AI kaynaklı yeni tehditler ekleniyor):

  1. Broken Object Level Authorization (BOLA/IDOR)

  2. Broken Authentication

  3. Excessive Data Exposure

  4. Unrestricted Resource Consumption (DoS)

  5. Broken Function Level Authorization

  6. Unrestricted Access to Sensitive Business Flows

  7. Server Side Request Forgery (SSRF)

  8. Security Misconfiguration

  9. Improper Inventory Management (zombie API'ler)

  10. Unsafe Consumption of APIs

2026 Ek İpuçları: AI prompt injection, machine identity auth (mTLS), zero-trust API.

Hosting Entegrasyonu: Kaliteweb ile API Barındırma

  • VPS/Bulut: Kaliteweb VPS'te Docker + PM2/Supervisor, auto-scaling.

  • Serverless: Vercel Functions, AWS Lambda, Railway – maliyet düşük, scaling otomatik.

  • İpuçları: API Gateway (Kong, AWS API Gateway) ile rate limiting/auth merkezi yönetin.

Yaygın Hatalar ve Debug Teknikleri

  • Hata: Rate limiting yok → DDoS.

  • Debug: Postman Collections, VS Code REST Client, Apollo DevTools.

  • Hata: JWT secret leak → .env + gitignore.

Gerçek Dünya Örnekleri

  • Ödeme: Stripe API entegrasyonu (webhook + idempotency key).

  • AI: OpenAI API (rate limiting + token budget yönetimi).

Sonuç + Gelecek Trendleri

2026'da API geliştirme multi-protocol: REST public, GraphQL client-facing, gRPC internal microservices. Gelecek: API Gateway'ler AI gateway'e dönüşüyor, gRPC adoption artıyor, serverless + edge API'ler standartlaşıyor.