Skip to main content

Item API

The Item API allows you to create optical items in bulk and retrieve paginated item listings. The bulk creation endpoint generates multiple item variants based on SPH (sphere) and CYL (cylinder) value ranges, creating all possible combinations. The listing endpoint provides flexible pagination, sorting, and filtering options.

Endpoint Details

Base URL: https://joptic.jethings.com

Required Headers


Create Bulk Items

Endpoint

Endpoint: POST /items/bulk
Content-Type: application/json

Request Structure

The request body contains an array of item configurations. Each item configuration will generate multiple items based on SPH and CYL value ranges. The system creates all combinations of SPH and CYL values within the specified ranges.

Request Body

Request Body Fields

ItemsDto Object

SPH Object

CYL Object

The system generates all combinations of SPH and CYL values within the specified ranges. For example, if SPH ranges from -2.00 to 2.00 with 0.25 increments, and CYL ranges from 0.00 to -2.00 with 0.25 increments, it will create multiple items (one for each combination).

Create Bulk Items Examples

Example 1: Create Single Item Configuration

Success Response:

Example 2: Create Multiple Item Configurations

Success Response:

Get All Items

Endpoint

Endpoint: GET /items

Query Parameters

The storeId is automatically extracted from the x-store-id header and does not need to be provided as a query parameter.

Sort Options

The sortBy parameter accepts the following values:
  • "createdAt" - Sort by creation date (default)
  • "updatedAt" - Sort by last update date
  • "name" - Sort by item name alphabetically

Get Items Examples

Example 1: Get All Items (Default Pagination)

Success Response:

Example 2: Get Items with Custom Pagination and Sorting


Example 3: Get Items Sorted by Update Date


Response Structures

Create Bulk Items Response

Get Items Response


Error Responses

400 Bad Request

Or for validation errors:

403 Forbidden

404 Not Found

500 Internal Server Error


Important Notes

Bulk Item Creation

  • The system generates all combinations of SPH and CYL values within specified ranges
  • Values are incremented by the jumpBy parameter
  • Both SPH and CYL ranges are inclusive (start and end values are included)
  • Values are rounded to 2 decimal places to avoid floating-point precision issues
  • Each item is named using the format: {indice} {treatment} {color} {sph.sign} {sph.value} {cly.sign} {cly.value}
  • Example: “1.5 Anti-Reflective Clear + 2.00 - 0.00”
  • The same name format is used for product title, item name, and item variant name
  • All items are created with the product type code “LENS”
  • The system automatically fetches the LENS product type from the database
  • If the LENS product type doesn’t exist, a 404 error is returned
  • Each item creates variants for: SPH, CYL, color, indice, and treatment
  • Variant values are stored separately for each property
  • This structure allows for flexible filtering and searching

Item Listing

Pagination Limits

Maximum 100 items per page
limit: 1-100

Soft Delete

Deleted items are excluded
deletedAt IS NULL

Pagination

Returns 10 most recent items by default

Sorting Options

The API supports sorting by:
  • Created At (sortBy=createdAt) - Creation timestamp (default)
  • Updated At (sortBy=updatedAt) - Last update timestamp
  • Name (sortBy=name) - Alphabetical sorting by item name
Both ascending (asc) and descending (desc) orders are supported.

Pagination Metadata

The pagination object includes:
  • page - Current page number
  • limit - Number of items per page
  • total - Total number of items matching the query
  • totalPages - Total number of pages
  • hasNext - Boolean indicating if there’s a next page
  • hasPrev - Boolean indicating if there’s a previous page

Item Status

  • Items are created with isActive: true by default
  • Status is returned as “active” or “unactive” in the response
  • Only non-deleted items are returned in GET requests

Summary

1

Authenticate

Obtain JWT token and ensure store access
2

Create Bulk Items

POST request with item configurations to create multiple items with SPH/CYL combinations
3

Retrieve Items

GET request with optional pagination, sorting, and filtering parameters
4

Handle Response

Process item data, batch information, or pagination metadata
This API provides comprehensive item management for optical stores, including bulk creation of lens items with automatic SPH/CYL combination generation, flexible querying with pagination and sorting, and efficient item retrieval.

Brand API

Create and manage optical brands

Customer API

Create and manage optical customers