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/bulkContent-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
| Field | Type | Required | Description |
|---|---|---|---|
items | array | ✅ Yes | Array of item configurations to create |
ItemsDto Object
| Field | Type | Required | Description |
|---|---|---|---|
indice | number | ✅ Yes | Index/refractive index value (e.g., “1.5”, “1.6”) |
treatment | string | ✅ Yes | Lens treatment type (e.g., “Anti-Reflective”, “Blue Light”) |
color | string | ✅ Yes | Lens color (e.g., “Clear”, “Brown”, “Gray”) |
sph | object | ✅ Yes | Sphere value range configuration |
cly | object | ✅ Yes | Cylinder value range configuration |
SPH Object
| Field | Type | Required | Description |
|---|---|---|---|
sph_start | string | ✅ Yes | Starting SPH value (e.g., “-2.00”) |
sph_end | string | ✅ Yes | Ending SPH value (e.g., “2.00”) |
sign_symbol | string | ✅ Yes | Sign symbol: ”+” or ”-“ |
jumpBy | string | ✅ Yes | Increment value between SPH values (e.g., “0.25”) |
CYL Object
| Field | Type | Required | Description |
|---|---|---|---|
cly_start | string | ✅ Yes | Starting CYL value (e.g., “0.00”) |
cly_end | string | ✅ Yes | Ending CYL value (e.g., “-2.00”) |
sign_symbol | string | ✅ Yes | Sign symbol: ”+” or ”-“ |
jumpBy | string | ✅ Yes | Increment value between CYL values (e.g., “0.25”) |
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
Example 2: Create Multiple Item Configurations
Get All Items
Endpoint
Endpoint:GET /items
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
page | number | No | 1 | Page number for pagination |
limit | number | No | 10 | Number of records per page (max 100) |
sortBy | string | No | createdAt | Sort field: “createdAt”, “updatedAt”, or “name” |
sortOrder | string | No | desc | Sort order: “asc” or “desc” |
The
storeId is automatically extracted from the x-store-id header and does not need to be provided as a query parameter.Sort Options
ThesortBy 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)
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
403 Forbidden
404 Not Found
500 Internal Server Error
Important Notes
Bulk Item Creation
Value Range Generation
Value Range Generation
- The system generates all combinations of SPH and CYL values within specified ranges
- Values are incremented by the
jumpByparameter - 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
Item Naming
Item Naming
- 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
Product Type
Product Type
- 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
Variant Structure
Variant Structure
- 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-100Soft Delete
Deleted items are excluded
deletedAt IS NULLPagination
- Default Behavior
- Custom Pagination
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
asc) and descending (desc) orders are supported.
Pagination Metadata
The pagination object includes:page- Current page numberlimit- Number of items per pagetotal- Total number of items matching the querytotalPages- Total number of pageshasNext- Boolean indicating if there’s a next pagehasPrev- Boolean indicating if there’s a previous page
Item Status
- Items are created with
isActive: trueby 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