API Guides

Standard Response Format

Allmine API HTTP response wrapper ve unwrap kuralları

Standard Response Format

Allmine HTTP endpoint'leri normalde BaseResponseDto<T> formatıyla döner. Endpoint reference içindeki schema'lar çoğu zaman data alanının tipini gösterir; client tarafında her response önce wrapper olarak ele alınmalıdır.

Başarılı response

{
  "isSuccess": true,
  "statusCode": 200,
  "data": {
    "_id": "65f000000000000000000001"
  },
  "errors": [],
  "timestamp": "2026-05-21T10:00:00.000Z"
}
AlanTipAçıklama
isSuccessbooleanBaşarı durumunu gösterir. Başarılı HTTP response'larda true beklenir.
statusCodenumberHTTP status code ile aynı olmalıdır. POST endpoint'lerinde genellikle 201 olabilir.
dataTEndpoint'in gerçek payload'ı. Liste, obje, boolean veya null olabilir.
errorsstring[]Başarılı cevaplarda boş array beklenir.
timestampstringResponse üretim zamanı. ISO date string gibi kullanılmalıdır.

Unwrap helper

Client kodu endpoint payload'ını kullanmadan önce wrapper'ı tek noktada açmalıdır.

export type BaseResponse<T> = {
  isSuccess: boolean;
  statusCode: number;
  data: T;
  errors?: string[];
  timestamp: string;
};

export function unwrap<T>(response: BaseResponse<T> | T): T {
  if (
    response &&
    typeof response === "object" &&
    "data" in response &&
    "isSuccess" in response
  ) {
    return (response as BaseResponse<T>).data;
  }

  return response as T;
}

204 ve boş response notu

Bazı delete endpoint'leri 204 No Content kullanır. Bu endpoint'lerde client boş body ile karşılaşabilir. Fetch/RTK Query gibi katmanlarda JSON parse etmeden önce response.status === 204 kontrolü yapılmalıdır.

async function parseApiResponse<T>(response: Response): Promise<T | null> {
  if (response.status === 204) {
    return null;
  }

  const json = await response.json();
  return unwrap<T>(json);
}

WebSocket response'ları

Socket.IO event payload'ları BaseResponseDto ile sarılmaz. Örneğin /live-stream-status içindeki subscribeError payload'ı { code, message } döner. Socket event'leri için ilgili guide veya mevcut socket dokümanındaki payload'lar baz alınmalıdır.

Webhook response'ları

POST /api/v1/revenuecat/webhook ve POST /api/v1/stripe/webhook HTTP endpoint olduğu için başarılı işlemde response body data.received=true olacak şekilde wrapper içinde dönebilir. Provider tarafında asıl önemli sinyal HTTP status code'dur.

On this page