Skip to content

API Коммерции

Общая информация

Базовый URL

/api/v1

Заголовок аутентификации

Authorization: Bearer <access_token>

Формат ответа

Все ответы следуют стандартному формату:

typescript
// Успешный ответ
interface SuccessResponse<T> {
  success: true;
  data: T;
  meta?: {
    pagination?: PaginationMeta;
    [key: string]: unknown;
  };
}

// Ответ с ошибкой
interface ErrorResponse {
  success: false;
  error: {
    code: string;
    message: string;
    details?: Record<string, string[]>;
  };
}

Формат пагинации

typescript
interface PaginationMeta {
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
  hasNext: boolean;
  hasPrevious: boolean;
}

Лимиты запросов

ЭндпоинтЛимит
Листинг/детали товаров200/мин
Операции с корзиной100/мин
POST /cart/checkout2/мин на пользователя
Операции с заказами100/мин

Заголовки лимитов для финансовых эндпоинтов

X-RateLimit-Limit: 2
X-RateLimit-Remaining: 1
X-RateLimit-Reset: 1705329600
X-RateLimit-Policy: financial

Эндпоинты товаров

GET /api/v1/products

Получение списка товаров с фильтрацией и пагинацией.

Аутентификация: Публичный

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>  (опционально - для персонализированных цен)

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
pagenumberНомер страницы (опционально)
pageSizenumberЭлементов на странице, макс. 100 (опционально)
categoryIdstringФильтр по UUID категории (опционально)
statusstringФильтр: 'ACTIVE', 'OUT_OF_STOCK' (опционально)
minPricenumberФильтр минимальной цены (опционально)
maxPricenumberФильтр максимальной цены (опционально)
searchstringПолнотекстовый поиск по названию/описанию (опционально)
sortBystringПоле сортировки: 'price', 'name', 'createdAt', 'popularity' (опционально)
sortOrderstringНаправление сортировки: 'asc', 'desc' (опционально)
tagsstringФильтр по тегам через запятую (опционально)

Ответ (200 OK)

typescript
interface ProductsResponse {
  products: Product[];
}

interface Product {
  id: string;
  name: string;
  slug: string;
  description: string;
  shortDescription: string | null;
  price: number;
  compareAtPrice: number | null;
  currency: string;
  sku: string;
  status: 'ACTIVE' | 'DRAFT' | 'ARCHIVED' | 'OUT_OF_STOCK';
  stockQuantity: number | null;
  category: {
    id: string;
    name: string;
    slug: string;
  } | null;
  images: {
    id: string;
    url: string;
    thumbnailUrl: string;
    alt: string | null;
    isPrimary: boolean;
  }[];
  tags: string[];
  rating: {
    average: number;
    count: number;
  };
  commissionPercentage: number;
  careerPointsPercentage: number;
  createdAt: string;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные параметры запроса

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/products?categoryId=cat-123&minPrice=1000&maxPrice=50000&sortBy=price&sortOrder=asc&page=1&pageSize=20"

Ответ:

json
{
  "success": true,
  "data": {
    "products": [
      {
        "id": "pp0e8400-e29b-41d4-a716-446655440001",
        "name": "Premium Health Supplement",
        "slug": "premium-health-supplement",
        "description": "A comprehensive health supplement with essential vitamins and minerals.",
        "shortDescription": "Essential vitamins and minerals",
        "price": 2500,
        "compareAtPrice": 3000,
        "currency": "RUB",
        "sku": "SUP-001",
        "status": "ACTIVE",
        "stockQuantity": 150,
        "category": {
          "id": "cat-123",
          "name": "Health Supplements",
          "slug": "health-supplements"
        },
        "images": [
          {
            "id": "img-001",
            "url": "https://cdn.iwm-platform.com/products/sup-001-full.jpg",
            "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
            "alt": "Premium Health Supplement bottle",
            "isPrimary": true
          }
        ],
        "tags": ["health", "vitamins", "bestseller"],
        "rating": {
          "average": 4.7,
          "count": 156
        },
        "commissionPercentage": 10,
        "careerPointsPercentage": 5,
        "createdAt": "2024-01-01T10:00:00Z"
      }
    ]
  },
  "meta": {
    "pagination": {
      "total": 85,
      "page": 1,
      "pageSize": 20,
      "totalPages": 5,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

GET /api/v1/products/:id

Получение детальной информации о товаре.

Аутентификация: Публичный

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>  (опционально - для персонализированных цен)

Параметры пути

ПараметрТипОписание
idstring (UUID)ID товара

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface ProductDetailResponse {
  id: string;
  name: string;
  slug: string;
  description: string;
  shortDescription: string | null;
  price: number;
  compareAtPrice: number | null;
  currency: string;
  sku: string;
  status: 'ACTIVE' | 'DRAFT' | 'ARCHIVED' | 'OUT_OF_STOCK';
  stockQuantity: number | null;
  trackInventory: boolean;
  weight: number | null;
  dimensions: {
    length: number | null;
    width: number | null;
    height: number | null;
  };
  category: {
    id: string;
    name: string;
    slug: string;
    breadcrumb: {
      id: string;
      name: string;
      slug: string;
    }[];
  } | null;
  images: {
    id: string;
    url: string;
    thumbnailUrl: string;
    alt: string | null;
    isPrimary: boolean;
    position: number;
  }[];
  variants: {
    id: string;
    name: string;
    sku: string;
    price: number;
    stockQuantity: number | null;
    attributes: Record<string, string>;
  }[];
  attributes: Record<string, string>;
  tags: string[];
  rating: {
    average: number;
    count: number;
    distribution: {
      1: number;
      2: number;
      3: number;
      4: number;
      5: number;
    };
  };
  commissionPercentage: number;
  careerPointsPercentage: number;
  relatedProducts: {
    id: string;
    name: string;
    slug: string;
    price: number;
    thumbnailUrl: string | null;
  }[];
  createdAt: string;
  updatedAt: string;
}

Ответы с ошибками

СтатусКодОписание
404PRODUCT_NOT_FOUNDТовар не найден

Пример

Запрос:

bash
curl -X GET https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001

Ответ:

json
{
  "success": true,
  "data": {
    "id": "pp0e8400-e29b-41d4-a716-446655440001",
    "name": "Premium Health Supplement",
    "slug": "premium-health-supplement",
    "description": "A comprehensive health supplement with essential vitamins and minerals for daily wellness.",
    "shortDescription": "Essential vitamins and minerals",
    "price": 2500,
    "compareAtPrice": 3000,
    "currency": "RUB",
    "sku": "SUP-001",
    "status": "ACTIVE",
    "stockQuantity": 150,
    "trackInventory": true,
    "weight": 250,
    "dimensions": {
      "length": 10,
      "width": 10,
      "height": 15
    },
    "category": {
      "id": "cat-123",
      "name": "Health Supplements",
      "slug": "health-supplements",
      "breadcrumb": [
        { "id": "cat-001", "name": "Health & Wellness", "slug": "health-wellness" },
        { "id": "cat-123", "name": "Health Supplements", "slug": "health-supplements" }
      ]
    },
    "images": [
      {
        "id": "img-001",
        "url": "https://cdn.iwm-platform.com/products/sup-001-full.jpg",
        "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
        "alt": "Premium Health Supplement bottle",
        "isPrimary": true,
        "position": 1
      }
    ],
    "variants": [],
    "attributes": {
      "servingSize": "2 capsules",
      "servingsPerContainer": "60",
      "form": "Capsules"
    },
    "tags": ["health", "vitamins", "bestseller"],
    "rating": {
      "average": 4.7,
      "count": 156,
      "distribution": {
        "1": 2,
        "2": 5,
        "3": 12,
        "4": 45,
        "5": 92
      }
    },
    "commissionPercentage": 10,
    "careerPointsPercentage": 5,
    "relatedProducts": [
      {
        "id": "pp0e8400-e29b-41d4-a716-446655440002",
        "name": "Omega-3 Fish Oil",
        "slug": "omega-3-fish-oil",
        "price": 1800,
        "thumbnailUrl": "https://cdn.iwm-platform.com/products/omega-thumb.jpg"
      }
    ],
    "createdAt": "2024-01-01T10:00:00Z",
    "updatedAt": "2024-01-15T12:00:00Z"
  }
}

GET /api/v1/products/:id/reviews

Получение отзывов о товаре.

Аутентификация: Публичный

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>  (опционально)

Параметры пути

ПараметрТипОписание
idstring (UUID)ID товара

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
pagenumberНомер страницы (опционально)
pageSizenumberЭлементов на странице, макс. 50 (опционально)
ratingnumberФильтр по рейтингу (1-5) (опционально)
sortBystringПоле сортировки: 'createdAt', 'rating', 'helpful' (опционально)
sortOrderstringНаправление сортировки: 'asc', 'desc' (опционально)

Ответ (200 OK)

typescript
interface ProductReviewsResponse {
  reviews: Review[];
  summary: {
    average: number;
    count: number;
    distribution: {
      1: number;
      2: number;
      3: number;
      4: number;
      5: number;
    };
  };
}

interface Review {
  id: string;
  author: {
    id: string;
    name: string;
    avatarUrl: string | null;
    isVerifiedPurchaser: boolean;
  };
  rating: number;
  title: string | null;
  content: string;
  pros: string[];
  cons: string[];
  helpfulCount: number;
  isHelpful: boolean | null;      // null если пользователь не аутентифицирован
  images: {
    url: string;
    thumbnailUrl: string;
  }[];
  response: {
    content: string;
    respondedAt: string;
  } | null;
  createdAt: string;
  updatedAt: string | null;
}

Ответы с ошибками

СтатусКодОписание
404PRODUCT_NOT_FOUNDТовар не найден

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001/reviews?page=1&pageSize=10&sortBy=helpful&sortOrder=desc"

Ответ:

json
{
  "success": true,
  "data": {
    "reviews": [
      {
        "id": "rv0e8400-e29b-41d4-a716-446655440001",
        "author": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "John D.",
          "avatarUrl": "https://cdn.iwm-platform.com/avatars/550e8400.jpg",
          "isVerifiedPurchaser": true
        },
        "rating": 5,
        "title": "Excellent quality supplement",
        "content": "I've been taking this supplement for a month and noticed significant improvement in my energy levels.",
        "pros": ["High quality ingredients", "Easy to swallow", "Fast shipping"],
        "cons": ["Price could be lower"],
        "helpfulCount": 24,
        "isHelpful": null,
        "images": [],
        "response": {
          "content": "Thank you for your feedback! We're glad you're enjoying the product.",
          "respondedAt": "2024-01-10T12:00:00Z"
        },
        "createdAt": "2024-01-08T15:30:00Z",
        "updatedAt": null
      }
    ],
    "summary": {
      "average": 4.7,
      "count": 156,
      "distribution": {
        "1": 2,
        "2": 5,
        "3": 12,
        "4": 45,
        "5": 92
      }
    }
  },
  "meta": {
    "pagination": {
      "total": 156,
      "page": 1,
      "pageSize": 10,
      "totalPages": 16,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

POST /api/v1/products/:id/reviews

Добавление отзыва о товаре.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID товара

Тело запроса

typescript
interface CreateReviewRequest {
  rating: number;                 // 1-5
  title?: string;                 // Опциональный заголовок (макс. 100 символов)
  content: string;                // Текст отзыва (мин. 10, макс. 2000 символов)
  pros?: string[];                // Список плюсов (макс. 5, каждый макс. 100 символов)
  cons?: string[];                // Список минусов (макс. 5, каждый макс. 100 символов)
}

Параметры запроса

Отсутствуют

Ответ (201 Created)

typescript
interface CreateReviewResponse {
  id: string;
  rating: number;
  title: string | null;
  content: string;
  pros: string[];
  cons: string[];
  status: 'PENDING' | 'PUBLISHED';
  createdAt: string;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные входные данные
401UNAUTHORIZEDНеверный или истекший токен доступа
403NOT_PURCHASEDДля отзыва необходимо приобрести товар
404PRODUCT_NOT_FOUNDТовар не найден
409ALREADY_REVIEWEDПользователь уже оставил отзыв на этот товар

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/products/pp0e8400-e29b-41d4-a716-446655440001/reviews \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "rating": 5,
    "title": "Great product",
    "content": "This supplement has really helped improve my daily energy levels. Highly recommend!",
    "pros": ["High quality", "Fast delivery"],
    "cons": ["Packaging could be better"]
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "id": "rv0e8400-e29b-41d4-a716-446655440002",
    "rating": 5,
    "title": "Great product",
    "content": "This supplement has really helped improve my daily energy levels. Highly recommend!",
    "pros": ["High quality", "Fast delivery"],
    "cons": ["Packaging could be better"],
    "status": "PENDING",
    "createdAt": "2024-01-15T20:00:00Z"
  }
}

Эндпоинты категорий

GET /api/v1/categories

Получение списка всех категорий.

Аутентификация: Публичный

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Не требуются

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
parentIdstringФильтр по родительской категории (опционально, null для корневых)
includeProductsbooleanВключить количество товаров (опционально)

Ответ (200 OK)

typescript
interface CategoriesResponse {
  categories: Category[];
}

interface Category {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  imageUrl: string | null;
  parentId: string | null;
  level: number;
  position: number;
  productCount: number | null;
  children: Category[];
  isActive: boolean;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные параметры запроса

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/categories?includeProducts=true"

Ответ:

json
{
  "success": true,
  "data": {
    "categories": [
      {
        "id": "cat-001",
        "name": "Health & Wellness",
        "slug": "health-wellness",
        "description": "Products for your health and wellbeing",
        "imageUrl": "https://cdn.iwm-platform.com/categories/health.jpg",
        "parentId": null,
        "level": 0,
        "position": 1,
        "productCount": 125,
        "children": [
          {
            "id": "cat-123",
            "name": "Health Supplements",
            "slug": "health-supplements",
            "description": "Vitamins, minerals, and supplements",
            "imageUrl": "https://cdn.iwm-platform.com/categories/supplements.jpg",
            "parentId": "cat-001",
            "level": 1,
            "position": 1,
            "productCount": 85,
            "children": [],
            "isActive": true
          }
        ],
        "isActive": true
      }
    ]
  }
}

GET /api/v1/categories/:id

Получение категории с товарами.

Аутентификация: Публичный

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Не требуются

Параметры пути

ПараметрТипОписание
idstring (UUID)ID категории

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
pagenumberНомер страницы для товаров (опционально)
pageSizenumberЭлементов на странице, макс. 100 (опционально)
sortBystringСортировка товаров: 'price', 'name', 'createdAt', 'popularity' (опционально)
sortOrderstringНаправление сортировки: 'asc', 'desc' (опционально)

Ответ (200 OK)

typescript
interface CategoryDetailResponse {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  imageUrl: string | null;
  parent: {
    id: string;
    name: string;
    slug: string;
  } | null;
  breadcrumb: {
    id: string;
    name: string;
    slug: string;
  }[];
  children: {
    id: string;
    name: string;
    slug: string;
    productCount: number;
  }[];
  products: Product[];
  filters: {
    priceRange: {
      min: number;
      max: number;
    };
    tags: {
      name: string;
      count: number;
    }[];
  };
}

Ответы с ошибками

СтатусКодОписание
404CATEGORY_NOT_FOUNDКатегория не найдена

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/categories/cat-123?page=1&pageSize=20"

Ответ:

json
{
  "success": true,
  "data": {
    "id": "cat-123",
    "name": "Health Supplements",
    "slug": "health-supplements",
    "description": "Vitamins, minerals, and supplements for daily wellness",
    "imageUrl": "https://cdn.iwm-platform.com/categories/supplements.jpg",
    "parent": {
      "id": "cat-001",
      "name": "Health & Wellness",
      "slug": "health-wellness"
    },
    "breadcrumb": [
      { "id": "cat-001", "name": "Health & Wellness", "slug": "health-wellness" },
      { "id": "cat-123", "name": "Health Supplements", "slug": "health-supplements" }
    ],
    "children": [
      { "id": "cat-124", "name": "Vitamins", "slug": "vitamins", "productCount": 32 },
      { "id": "cat-125", "name": "Minerals", "slug": "minerals", "productCount": 18 }
    ],
    "products": [],
    "filters": {
      "priceRange": {
        "min": 500,
        "max": 15000
      },
      "tags": [
        { "name": "vitamins", "count": 32 },
        { "name": "bestseller", "count": 15 }
      ]
    }
  },
  "meta": {
    "pagination": {
      "total": 85,
      "page": 1,
      "pageSize": 20,
      "totalPages": 5,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

Эндпоинты корзины

GET /api/v1/cart

Получение текущей корзины.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface CartResponse {
  id: string;
  items: CartItem[];
  summary: {
    subtotal: number;
    discount: number;
    shipping: number | null;
    tax: number;
    total: number;
    currency: string;
    itemCount: number;
    totalQuantity: number;
  };
  appliedCoupons: {
    code: string;
    discount: number;
    type: 'PERCENTAGE' | 'FIXED';
  }[];
  estimatedCommission: number | null;
  estimatedCareerPoints: number | null;
  updatedAt: string;
}

interface CartItem {
  id: string;
  product: {
    id: string;
    name: string;
    slug: string;
    sku: string;
    price: number;
    compareAtPrice: number | null;
    thumbnailUrl: string | null;
    status: string;
    stockQuantity: number | null;
  };
  variantId: string | null;
  variantAttributes: Record<string, string> | null;
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  addedAt: string;
}

Ответы с ошибками

СтатусКодОписание
401UNAUTHORIZEDНеверный или истекший токен доступа

Пример

Запрос:

bash
curl -X GET https://api.iwm-platform.com/api/v1/cart \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "id": "ct0e8400-e29b-41d4-a716-446655440001",
    "items": [
      {
        "id": "ci0e8400-e29b-41d4-a716-446655440001",
        "product": {
          "id": "pp0e8400-e29b-41d4-a716-446655440001",
          "name": "Premium Health Supplement",
          "slug": "premium-health-supplement",
          "sku": "SUP-001",
          "price": 2500,
          "compareAtPrice": 3000,
          "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg",
          "status": "ACTIVE",
          "stockQuantity": 150
        },
        "variantId": null,
        "variantAttributes": null,
        "quantity": 2,
        "unitPrice": 2500,
        "totalPrice": 5000,
        "addedAt": "2024-01-15T18:00:00Z"
      }
    ],
    "summary": {
      "subtotal": 5000,
      "discount": 0,
      "shipping": null,
      "tax": 1000,
      "total": 6000,
      "currency": "RUB",
      "itemCount": 1,
      "totalQuantity": 2
    },
    "appliedCoupons": [],
    "estimatedCommission": null,
    "estimatedCareerPoints": null,
    "updatedAt": "2024-01-15T18:00:00Z"
  }
}

POST /api/v1/cart/items

Добавление товара в корзину.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Тело запроса

typescript
interface AddCartItemRequest {
  productId: string;              // UUID товара
  variantId?: string;             // UUID варианта товара (если применимо)
  quantity: number;               // Количество для добавления (мин. 1)
}

Параметры запроса

Отсутствуют

Ответ (201 Created)

typescript
interface AddCartItemResponse {
  cartItemId: string;
  product: {
    id: string;
    name: string;
  };
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные входные данные
401UNAUTHORIZEDНеверный или истекший токен доступа
404PRODUCT_NOT_FOUNDТовар не найден
404VARIANT_NOT_FOUNDВариант товара не найден
400PRODUCT_UNAVAILABLEТовар недоступен
400INSUFFICIENT_STOCKНедостаточно товара на складе
400MAX_QUANTITY_EXCEEDEDПревышено максимальное количество товара

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/cart/items \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "pp0e8400-e29b-41d4-a716-446655440001",
    "quantity": 2
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "product": {
      "id": "pp0e8400-e29b-41d4-a716-446655440001",
      "name": "Premium Health Supplement"
    },
    "quantity": 2,
    "unitPrice": 2500,
    "totalPrice": 5000,
    "cartSummary": {
      "total": 6000,
      "itemCount": 1,
      "totalQuantity": 2
    }
  }
}

PATCH /api/v1/cart/items/:id

Обновление количества товара в корзине.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID элемента корзины

Тело запроса

typescript
interface UpdateCartItemRequest {
  quantity: number;               // Новое количество (мин. 1)
}

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface UpdateCartItemResponse {
  cartItemId: string;
  quantity: number;
  unitPrice: number;
  totalPrice: number;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверное количество
401UNAUTHORIZEDНеверный или истекший токен доступа
404CART_ITEM_NOT_FOUNDЭлемент корзины не найден
400INSUFFICIENT_STOCKНедостаточно товара на складе
400MAX_QUANTITY_EXCEEDEDПревышено максимальное количество

Пример

Запрос:

bash
curl -X PATCH https://api.iwm-platform.com/api/v1/cart/items/ci0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 3
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "quantity": 3,
    "unitPrice": 2500,
    "totalPrice": 7500,
    "cartSummary": {
      "total": 9000,
      "itemCount": 1,
      "totalQuantity": 3
    }
  }
}

DELETE /api/v1/cart/items/:id

Удаление товара из корзины.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID элемента корзины

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface RemoveCartItemResponse {
  message: string;
  cartItemId: string;
  cartSummary: {
    total: number;
    itemCount: number;
    totalQuantity: number;
  };
}

Ответы с ошибками

СтатусКодОписание
401UNAUTHORIZEDНеверный или истекший токен доступа
404CART_ITEM_NOT_FOUNDЭлемент корзины не найден

Пример

Запрос:

bash
curl -X DELETE https://api.iwm-platform.com/api/v1/cart/items/ci0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "message": "Item removed from cart",
    "cartItemId": "ci0e8400-e29b-41d4-a716-446655440001",
    "cartSummary": {
      "total": 0,
      "itemCount": 0,
      "totalQuantity": 0
    }
  }
}

DELETE /api/v1/cart

Очистка корзины.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface ClearCartResponse {
  message: string;
  itemsRemoved: number;
}

Ответы с ошибками

СтатусКодОписание
401UNAUTHORIZEDНеверный или истекший токен доступа

Пример

Запрос:

bash
curl -X DELETE https://api.iwm-platform.com/api/v1/cart \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "message": "Cart cleared successfully",
    "itemsRemoved": 3
  }
}

POST /api/v1/cart/checkout

Начало процесса оформления заказа.

Аутентификация: Обязательна

Лимит запросов: 2 запроса в минуту (финансовый эндпоинт)

Заголовки запроса

Authorization: Bearer <access_token>

Тело запроса

typescript
interface CheckoutRequest {
  shippingAddressId: string;      // ID сохраненного адреса
  billingAddressId?: string;      // Если отличается от адреса доставки
  shippingMethodId: string;       // Выбранный способ доставки
  paymentMethod: 'CARD' | 'BANK_TRANSFER' | 'EWALLET' | 'BALANCE';
  couponCodes?: string[];         // Применяемые промокоды
  notes?: string;                 // Примечания к заказу
  usePartnerBalance?: boolean;    // Использовать партнерский баланс для оплаты
}

Параметры запроса

Отсутствуют

Ответ (201 Created)

typescript
interface CheckoutResponse {
  orderId: string;
  orderNumber: string;
  status: 'PENDING_PAYMENT';
  payment: {
    method: string;
    amount: number;
    currency: string;
    // Для оплаты картой
    paymentUrl?: string;
    // Для банковского перевода
    bankDetails?: {
      bankName: string;
      accountNumber: string;
      bik: string;
      purpose: string;
    };
    expiresAt: string;
  };
  summary: {
    subtotal: number;
    discount: number;
    shipping: number;
    tax: number;
    total: number;
  };
  estimatedDelivery: string | null;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные входные данные
400CART_EMPTYКорзина пуста
400ITEMS_UNAVAILABLEНекоторые товары больше недоступны
400INSUFFICIENT_STOCKНедостаточно товара на складе для некоторых позиций
400INVALID_ADDRESSНеверный адрес доставки
400INVALID_SHIPPING_METHODСпособ доставки недоступен
400INVALID_COUPONПромокод недействителен или истек
401UNAUTHORIZEDНеверный или истекший токен доступа
403KYC_REQUIREDДля этой покупки требуется KYC-верификация
429RATE_LIMIT_EXCEEDEDСлишком много попыток оформления заказа

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/cart/checkout \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "shippingAddressId": "aa0e8400-e29b-41d4-a716-446655440000",
    "shippingMethodId": "ship-001",
    "paymentMethod": "CARD",
    "couponCodes": ["WELCOME10"]
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "PENDING_PAYMENT",
    "payment": {
      "method": "CARD",
      "amount": 8100,
      "currency": "RUB",
      "paymentUrl": "https://payment.iwm-platform.com/pay/abc123",
      "expiresAt": "2024-01-15T22:00:00Z"
    },
    "summary": {
      "subtotal": 7500,
      "discount": 750,
      "shipping": 350,
      "tax": 1000,
      "total": 8100
    },
    "estimatedDelivery": "2024-01-20"
  }
}

Эндпоинты заказов

GET /api/v1/orders

Получение списка заказов.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
pagenumberНомер страницы (опционально)
pageSizenumberЭлементов на странице, макс. 50 (опционально)
statusstringФильтр по статусу (опционально)
dateFromstringНачальная дата (ISO 8601) (опционально)
dateTostringКонечная дата (ISO 8601) (опционально)

Ответ (200 OK)

typescript
interface OrdersResponse {
  orders: OrderSummary[];
}

interface OrderSummary {
  id: string;
  orderNumber: string;
  status: 'PENDING_PAYMENT' | 'PAID' | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' | 'CANCELLED' | 'REFUNDED';
  paymentStatus: 'PENDING' | 'PAID' | 'FAILED' | 'REFUNDED';
  itemCount: number;
  total: number;
  currency: string;
  createdAt: string;
  updatedAt: string;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные параметры запроса
401UNAUTHORIZEDНеверный или истекший токен доступа

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/orders?status=DELIVERED&page=1&pageSize=10" \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "orders": [
      {
        "id": "or0e8400-e29b-41d4-a716-446655440001",
        "orderNumber": "ORD-2024-00001234",
        "status": "DELIVERED",
        "paymentStatus": "PAID",
        "itemCount": 3,
        "total": 8100,
        "currency": "RUB",
        "createdAt": "2024-01-10T14:00:00Z",
        "updatedAt": "2024-01-15T10:00:00Z"
      }
    ]
  },
  "meta": {
    "pagination": {
      "total": 15,
      "page": 1,
      "pageSize": 10,
      "totalPages": 2,
      "hasNext": true,
      "hasPrevious": false
    }
  }
}

GET /api/v1/orders/:id

Получение детальной информации о заказе.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID заказа

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface OrderDetailResponse {
  id: string;
  orderNumber: string;
  status: string;
  paymentStatus: string;
  items: {
    id: string;
    product: {
      id: string;
      name: string;
      sku: string;
      thumbnailUrl: string | null;
    };
    variantId: string | null;
    variantAttributes: Record<string, string> | null;
    quantity: number;
    unitPrice: number;
    totalPrice: number;
  }[];
  pricing: {
    subtotal: number;
    discount: number;
    shipping: number;
    tax: number;
    total: number;
    currency: string;
  };
  shippingAddress: {
    recipientName: string;
    street: string;
    city: string;
    region: string;
    country: string;
    postalCode: string;
    phone: string | null;
  };
  billingAddress: {
    street: string;
    city: string;
    region: string;
    country: string;
    postalCode: string;
  } | null;
  shippingMethod: {
    name: string;
    carrier: string | null;
    estimatedDelivery: string | null;
  };
  payment: {
    method: string;
    transactionId: string | null;
    paidAt: string | null;
  };
  appliedCoupons: {
    code: string;
    discount: number;
  }[];
  notes: string | null;
  statusHistory: {
    status: string;
    changedAt: string;
    note: string | null;
  }[];
  canCancel: boolean;
  canRefund: boolean;
  createdAt: string;
  updatedAt: string;
}

Ответы с ошибками

СтатусКодОписание
401UNAUTHORIZEDНеверный или истекший токен доступа
404ORDER_NOT_FOUNDЗаказ не найден

Пример

Запрос:

bash
curl -X GET https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001 \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "id": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "DELIVERED",
    "paymentStatus": "PAID",
    "items": [
      {
        "id": "oi0e8400-e29b-41d4-a716-446655440001",
        "product": {
          "id": "pp0e8400-e29b-41d4-a716-446655440001",
          "name": "Premium Health Supplement",
          "sku": "SUP-001",
          "thumbnailUrl": "https://cdn.iwm-platform.com/products/sup-001-thumb.jpg"
        },
        "variantId": null,
        "variantAttributes": null,
        "quantity": 3,
        "unitPrice": 2500,
        "totalPrice": 7500
      }
    ],
    "pricing": {
      "subtotal": 7500,
      "discount": 750,
      "shipping": 350,
      "tax": 1000,
      "total": 8100,
      "currency": "RUB"
    },
    "shippingAddress": {
      "recipientName": "John Doe",
      "street": "Tverskaya 15, apt. 42",
      "city": "Moscow",
      "region": "Moscow Oblast",
      "country": "RU",
      "postalCode": "125009",
      "phone": "+79991234567"
    },
    "billingAddress": null,
    "shippingMethod": {
      "name": "Standard Delivery",
      "carrier": "Russian Post",
      "estimatedDelivery": "2024-01-20"
    },
    "payment": {
      "method": "CARD",
      "transactionId": "TXN-2024011500001",
      "paidAt": "2024-01-10T14:05:00Z"
    },
    "appliedCoupons": [
      {
        "code": "WELCOME10",
        "discount": 750
      }
    ],
    "notes": null,
    "statusHistory": [
      { "status": "PENDING_PAYMENT", "changedAt": "2024-01-10T14:00:00Z", "note": null },
      { "status": "PAID", "changedAt": "2024-01-10T14:05:00Z", "note": "Payment confirmed" },
      { "status": "PROCESSING", "changedAt": "2024-01-11T09:00:00Z", "note": null },
      { "status": "SHIPPED", "changedAt": "2024-01-12T15:00:00Z", "note": "Tracking: RP123456789RU" },
      { "status": "DELIVERED", "changedAt": "2024-01-15T10:00:00Z", "note": null }
    ],
    "canCancel": false,
    "canRefund": true,
    "createdAt": "2024-01-10T14:00:00Z",
    "updatedAt": "2024-01-15T10:00:00Z"
  }
}

GET /api/v1/orders/:id/tracking

Получение информации об отслеживании.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID заказа

Тело запроса

Отсутствует

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface TrackingResponse {
  orderId: string;
  orderNumber: string;
  status: string;
  carrier: string | null;
  trackingNumber: string | null;
  trackingUrl: string | null;
  estimatedDelivery: string | null;
  events: {
    status: string;
    location: string | null;
    description: string;
    timestamp: string;
  }[];
  shippedAt: string | null;
  deliveredAt: string | null;
}

Ответы с ошибками

СтатусКодОписание
401UNAUTHORIZEDНеверный или истекший токен доступа
404ORDER_NOT_FOUNDЗаказ не найден
400NOT_SHIPPEDЗаказ еще не отправлен

Пример

Запрос:

bash
curl -X GET https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001/tracking \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

Ответ:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "DELIVERED",
    "carrier": "Russian Post",
    "trackingNumber": "RP123456789RU",
    "trackingUrl": "https://pochta.ru/tracking#RP123456789RU",
    "estimatedDelivery": "2024-01-20",
    "events": [
      {
        "status": "DELIVERED",
        "location": "Moscow",
        "description": "Package delivered",
        "timestamp": "2024-01-15T10:00:00Z"
      },
      {
        "status": "OUT_FOR_DELIVERY",
        "location": "Moscow",
        "description": "Out for delivery",
        "timestamp": "2024-01-15T08:00:00Z"
      },
      {
        "status": "IN_TRANSIT",
        "location": "Moscow Sorting Center",
        "description": "Arrived at sorting center",
        "timestamp": "2024-01-14T16:00:00Z"
      },
      {
        "status": "SHIPPED",
        "location": "Warehouse",
        "description": "Package shipped",
        "timestamp": "2024-01-12T15:00:00Z"
      }
    ],
    "shippedAt": "2024-01-12T15:00:00Z",
    "deliveredAt": "2024-01-15T10:00:00Z"
  }
}

POST /api/v1/orders/:id/cancel

Отмена заказа.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID заказа

Тело запроса

typescript
interface CancelOrderRequest {
  reason: string;                 // Причина отмены
}

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface CancelOrderResponse {
  orderId: string;
  orderNumber: string;
  status: 'CANCELLED';
  refundStatus: 'PENDING' | 'PROCESSING' | 'COMPLETED' | null;
  refundAmount: number | null;
  message: string;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORПричина не указана
401UNAUTHORIZEDНеверный или истекший токен доступа
404ORDER_NOT_FOUNDЗаказ не найден
400CANNOT_CANCELЗаказ не может быть отменен (уже отправлен/доставлен)

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440002/cancel \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Changed my mind"
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "orderId": "or0e8400-e29b-41d4-a716-446655440002",
    "orderNumber": "ORD-2024-00001235",
    "status": "CANCELLED",
    "refundStatus": "PENDING",
    "refundAmount": 5000,
    "message": "Order cancelled successfully. Refund will be processed within 3-5 business days."
  }
}

POST /api/v1/orders/:id/refund

Запрос на возврат средств.

Аутентификация: Обязательна

Лимит запросов: 100 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>

Параметры пути

ПараметрТипОписание
idstring (UUID)ID заказа

Тело запроса

typescript
interface RefundRequest {
  reason: string;                 // Причина возврата
  itemIds?: string[];             // ID конкретных товаров для возврата (опционально, все если не указано)
  description?: string;           // Дополнительное описание
}

Параметры запроса

Отсутствуют

Ответ (201 Created)

typescript
interface RefundResponse {
  refundRequestId: string;
  orderId: string;
  orderNumber: string;
  status: 'PENDING_REVIEW';
  requestedAmount: number;
  items: {
    itemId: string;
    productName: string;
    quantity: number;
    amount: number;
  }[];
  message: string;
  createdAt: string;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные входные данные
401UNAUTHORIZEDНеверный или истекший токен доступа
404ORDER_NOT_FOUNDЗаказ не найден
400CANNOT_REFUNDЗаказ не подлежит возврату
400REFUND_PERIOD_EXPIREDСрок возврата истек
409REFUND_ALREADY_REQUESTEDЗапрос на возврат уже создан

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/orders/or0e8400-e29b-41d4-a716-446655440001/refund \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Product defective",
    "description": "The supplement bottle cap was damaged on arrival"
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "refundRequestId": "rf0e8400-e29b-41d4-a716-446655440001",
    "orderId": "or0e8400-e29b-41d4-a716-446655440001",
    "orderNumber": "ORD-2024-00001234",
    "status": "PENDING_REVIEW",
    "requestedAmount": 8100,
    "items": [
      {
        "itemId": "oi0e8400-e29b-41d4-a716-446655440001",
        "productName": "Premium Health Supplement",
        "quantity": 3,
        "amount": 7500
      }
    ],
    "message": "Refund request submitted. You will be notified once reviewed.",
    "createdAt": "2024-01-15T21:00:00Z"
  }
}

Эндпоинты доставки

GET /api/v1/shipping/methods

Получение доступных способов доставки.

Аутентификация: Опционально

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>  (опционально)

Тело запроса

Отсутствует

Параметры запроса

ПараметрТипОписание
countrystringКод страны назначения (ISO 3166-1 alpha-2)
postalCodestringПочтовый индекс назначения (опционально)
cartIdstringID корзины для точного расчета (опционально)

Ответ (200 OK)

typescript
interface ShippingMethodsResponse {
  methods: ShippingMethod[];
}

interface ShippingMethod {
  id: string;
  name: string;
  carrier: string;
  description: string | null;
  estimatedDays: {
    min: number;
    max: number;
  };
  price: number;
  currency: string;
  isFree: boolean;
  freeThreshold: number | null;
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверный код страны
400SHIPPING_NOT_AVAILABLEДоставка в этот регион недоступна

Пример

Запрос:

bash
curl -X GET "https://api.iwm-platform.com/api/v1/shipping/methods?country=RU&postalCode=125009"

Ответ:

json
{
  "success": true,
  "data": {
    "methods": [
      {
        "id": "ship-001",
        "name": "Standard Delivery",
        "carrier": "Russian Post",
        "description": "Delivered to your nearest post office",
        "estimatedDays": {
          "min": 5,
          "max": 10
        },
        "price": 350,
        "currency": "RUB",
        "isFree": false,
        "freeThreshold": 5000
      },
      {
        "id": "ship-002",
        "name": "Express Delivery",
        "carrier": "CDEK",
        "description": "Fast delivery to your door",
        "estimatedDays": {
          "min": 2,
          "max": 4
        },
        "price": 650,
        "currency": "RUB",
        "isFree": false,
        "freeThreshold": 10000
      }
    ]
  }
}

POST /api/v1/shipping/calculate

Расчет стоимости доставки.

Аутентификация: Опционально

Лимит запросов: 200 запросов в минуту

Заголовки запроса

Authorization: Bearer <access_token>  (опционально)

Тело запроса

typescript
interface CalculateShippingRequest {
  destination: {
    country: string;              // ISO 3166-1 alpha-2
    region?: string;
    city?: string;
    postalCode: string;
  };
  items: {
    productId: string;
    quantity: number;
    variantId?: string;
  }[];
  // ИЛИ
  cartId?: string;                // Использовать товары из текущей корзины
}

Параметры запроса

Отсутствуют

Ответ (200 OK)

typescript
interface CalculateShippingResponse {
  destination: {
    country: string;
    postalCode: string;
  };
  package: {
    totalWeight: number;
    dimensions: {
      length: number;
      width: number;
      height: number;
    };
  };
  options: {
    methodId: string;
    name: string;
    carrier: string;
    price: number;
    currency: string;
    estimatedDelivery: {
      min: string;                // ISO 8601 дата
      max: string;                // ISO 8601 дата
    };
    isFree: boolean;
  }[];
}

Ответы с ошибками

СтатусКодОписание
400VALIDATION_ERRORНеверные входные данные
400INVALID_DESTINATIONНевозможно доставить по этому адресу
404PRODUCT_NOT_FOUNDОдин или несколько товаров не найдены

Пример

Запрос:

bash
curl -X POST https://api.iwm-platform.com/api/v1/shipping/calculate \
  -H "Content-Type: application/json" \
  -d '{
    "destination": {
      "country": "RU",
      "postalCode": "125009"
    },
    "items": [
      {
        "productId": "pp0e8400-e29b-41d4-a716-446655440001",
        "quantity": 3
      }
    ]
  }'

Ответ:

json
{
  "success": true,
  "data": {
    "destination": {
      "country": "RU",
      "postalCode": "125009"
    },
    "package": {
      "totalWeight": 750,
      "dimensions": {
        "length": 25,
        "width": 15,
        "height": 20
      }
    },
    "options": [
      {
        "methodId": "ship-001",
        "name": "Standard Delivery",
        "carrier": "Russian Post",
        "price": 350,
        "currency": "RUB",
        "estimatedDelivery": {
          "min": "2024-01-20",
          "max": "2024-01-25"
        },
        "isFree": false
      },
      {
        "methodId": "ship-002",
        "name": "Express Delivery",
        "carrier": "CDEK",
        "price": 650,
        "currency": "RUB",
        "estimatedDelivery": {
          "min": "2024-01-17",
          "max": "2024-01-19"
        },
        "isFree": false
      }
    ]
  }
}

Связанные документы