Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save numpde/adaed9b578749656af78b8c5bc560d5f to your computer and use it in GitHub Desktop.
Save numpde/adaed9b578749656af78b8c5bc560d5f to your computer and use it in GitHub Desktop.
OpenAPI for the WP/WC (basic product management)
openapi: 3.1.0
info:
summary: OpenAPI for the WP/WC (basic product management). Based on the doc from the WP plug-in by Schneider & Schuetz GmbH.
title: wc/v3
version: '1'
servers:
- url: ***************************
security:
- basicAuth: []
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
schemas:
batch:
type: object
properties:
update:
type: array
items:
$ref: '#/components/schemas/product' # Each item references the product schema
WPError:
properties:
additional_data:
description: Additional data of the error
type: object
additional_errors:
description: More errors
type: object
code:
description: The error code
type: string
data:
description: Data of the error
type: object
message:
description: The description of the error
type: string
type: object
product:
properties:
attributes:
description: List of attributes.
items:
properties:
id:
description: Attribute ID.
type: integer
name:
description: Attribute name.
type: string
options:
description: List of available term names of the attribute.
items:
type: string
type: array
position:
description: Attribute position.
type: integer
variation:
description: Define if the attribute can be used as variation.
type: boolean
visible:
description: Define if the attribute is visible on the "Additional
information" tab in the product's page.
type: boolean
type: object
type: array
average_rating:
description: Reviews average rating.
type: string
backordered:
description: Shows if the product is on backordered.
type: boolean
backorders:
description: If managing stock, this controls if backorders are allowed.
enum:
- 'no'
- notify
- 'yes'
type: string
backorders_allowed:
description: Shows if backorders are allowed.
type: boolean
button_text:
description: Product external button text. Only for external products.
type: string
catalog_visibility:
description: Catalog visibility.
enum:
- visible
- catalog
- search
- hidden
type: string
categories:
description: List of categories.
items:
properties:
id:
description: Category ID.
type: integer
name:
description: Category name.
type: string
slug:
description: Category slug.
type: string
type: object
type: array
cross_sell_ids:
description: List of cross-sell products IDs.
items:
type: integer
type: array
date_created:
description: The date the product was created, in the site's timezone.
type: string
date_created_gmt:
description: The date the product was created, as GMT.
type: string
date_modified:
description: The date the product was last modified, in the site's timezone.
type: string
date_modified_gmt:
description: The date the product was last modified, as GMT.
type: string
date_on_sale_from:
description: Start date of sale price, in the site's timezone.
type: string
date_on_sale_from_gmt:
description: Start date of sale price, as GMT.
type: string
date_on_sale_to:
description: End date of sale price, in the site's timezone.
type: string
date_on_sale_to_gmt:
description: End date of sale price, in the site's timezone.
type: string
default_attributes:
description: Defaults variation attributes.
items:
properties:
id:
description: Attribute ID.
type: integer
name:
description: Attribute name.
type: string
option:
description: Selected attribute term name.
type: string
type: object
type: array
description:
description: Product description.
type: string
dimensions:
description: Product dimensions.
properties:
height:
description: Product height (cm).
type: string
length:
description: Product length (cm).
type: string
width:
description: Product width (cm).
type: string
type: object
download_expiry:
description: Number of days until access to downloadable files expires.
type: integer
download_limit:
description: Number of times downloadable files can be downloaded after
purchase.
type: integer
downloadable:
description: If the product is downloadable.
type: boolean
downloads:
description: List of downloadable files.
items:
properties:
file:
description: File URL.
type: string
id:
description: File ID.
type: string
name:
description: File name.
type: string
type: object
type: array
external_url:
description: Product external URL. Only for external products.
format: uri
type: string
featured:
description: Featured product.
type: boolean
generated_slug:
description: Slug automatically generated from the product name.
type: string
global_unique_id:
description: GTIN, UPC, EAN or ISBN.
type: string
grouped_products:
description: List of grouped products ID.
items:
type: integer
type: array
has_options:
description: Shows if the product needs to be configured before it can be
bought.
type: boolean
id:
description: Unique identifier for the resource.
type: integer
images:
description: List of images.
items:
properties:
alt:
description: Image alternative text.
type: string
date_created:
description: The date the image was created, in the site's timezone.
type: string
date_created_gmt:
description: The date the image was created, as GMT.
type: string
date_modified:
description: The date the image was last modified, in the site's timezone.
type: string
date_modified_gmt:
description: The date the image was last modified, as GMT.
type: string
id:
description: Image ID.
type: integer
name:
description: Image name.
type: string
src:
description: Image URL.
format: uri
type: string
type: object
type: array
low_stock_amount:
description: Low Stock amount for the product.
type:
- integer
- 'null'
manage_stock:
description: Stock management at product level.
type: boolean
menu_order:
description: Menu order, used to custom sort products.
type: integer
meta_data:
description: Meta data.
type: array
items:
type: object
properties:
id:
description: Meta ID.
type: integer
key:
description: Meta key.
type: string
value:
description: Meta value.
oneOf:
- type: string
- type: integer
- type: boolean
- type: object
- type: array
items:
type: string # Define the type of items in the array
name:
description: Product name.
type: string
on_sale:
description: Shows if the product is on sale.
type: boolean
parent_id:
description: Product parent ID.
type: integer
permalink:
description: Product URL.
format: uri
type: string
permalink_template:
description: Permalink template for the product.
type: string
post_password:
description: Post password.
type: string
price:
description: Current product price.
type: string
price_html:
description: Price formatted in HTML.
type: string
purchasable:
description: Shows if the product can be bought.
type: boolean
purchase_note:
description: Optional note to send the customer after purchase.
type: string
rating_count:
description: Amount of reviews that the product have.
type: integer
regular_price:
description: Product regular price.
type: string
related_ids:
description: List of related products IDs.
items:
type: integer
type: array
reviews_allowed:
description: Allow reviews.
type: boolean
sale_price:
description: Product sale price.
type: string
shipping_class:
description: Shipping class slug.
type: string
shipping_class_id:
description: Shipping class ID.
type: string
shipping_required:
description: Shows if the product need to be shipped.
type: boolean
shipping_taxable:
description: Shows whether or not the product shipping is taxable.
type: boolean
short_description:
description: Product short description.
type: string
sku:
description: Stock Keeping Unit.
type: string
slug:
description: Product slug.
type: string
sold_individually:
description: Allow one item to be bought in a single order.
type: boolean
status:
description: Product status (post status).
enum:
- draft
- pending
- private
- publish
- future
- auto-draft
- trash
type: string
stock_quantity:
description: Stock quantity.
type: integer
stock_status:
description: Controls the stock status of the product.
enum:
- instock
- outofstock
- onbackorder
type: string
tags:
description: List of tags.
items:
properties:
id:
description: Tag ID.
type: integer
name:
description: Tag name.
type: string
slug:
description: Tag slug.
type: string
type: object
type: array
tax_class:
description: Tax class.
type: string
tax_status:
description: Tax status.
enum:
- taxable
- shipping
- none
type: string
total_sales:
description: Amount of sales.
type: integer
type:
description: Product type.
enum:
- simple
- grouped
- external
- variable
type: string
upsell_ids:
description: List of up-sell products IDs.
items:
type: integer
type: array
variations:
description: List of variations IDs.
items:
type: integer
type: array
virtual:
description: If the product is virtual.
type: boolean
weight:
description: Product weight (kg).
type: string
type: object
paths:
/:
get:
operationId:
rootPing
responses:
'200':
description: OK
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/WPError'
'404':
description: Not Found
tags:
- root
parameters:
- name: namespace
in: query
description: ''
required: false
schema:
type: string
- name: context
in: query
description: ''
required: false
schema:
type: string
/products:
get:
operationId:
getProducts
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/product'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/WPError'
'404':
description: Not Found
tags:
- root
parameters:
- name: context
in: query
description: >-
Scope under which the request is made; determines fields present in
response.
required: false
schema:
type: string
description: >-
Scope under which the request is made; determines fields present
in response.
enum:
- view
- edit
- name: page
in: query
description: Current page of the collection.
required: false
schema:
type: integer
description: Current page of the collection.
- name: per_page
in: query
description: Maximum number of items to be returned in result set.
required: false
schema:
type: integer
description: Maximum number of items to be returned in result set.
- name: search
in: query
description: Limit results to those matching a string.
required: false
schema:
type: string
description: Limit results to those matching a string.
- name: after
in: query
description: >-
Limit response to resources published after a given ISO8601
compliant date.
required: false
schema:
type: string
format: date-time
description: >-
Limit response to resources published after a given ISO8601
compliant date.
- name: before
in: query
description: >-
Limit response to resources published before a given ISO8601
compliant date.
required: false
schema:
type: string
format: date-time
description: >-
Limit response to resources published before a given ISO8601
compliant date.
- name: modified_after
in: query
description: >-
Limit response to resources modified after a given ISO8601 compliant
date.
required: false
schema:
type: string
format: date-time
description: >-
Limit response to resources modified after a given ISO8601
compliant date.
- name: modified_before
in: query
description: >-
Limit response to resources modified before a given ISO8601
compliant date.
required: false
schema:
type: string
format: date-time
description: >-
Limit response to resources modified before a given ISO8601
compliant date.
- name: dates_are_gmt
in: query
description: >-
Whether to consider GMT post dates when limiting response by
published or modified date.
required: false
schema:
type: boolean
description: >-
Whether to consider GMT post dates when limiting response by
published or modified date.
- name: exclude
in: query
description: Ensure result set excludes specific IDs.
required: false
schema:
type: array
items:
type: integer
description: Ensure result set excludes specific IDs.
- name: include
in: query
description: Limit result set to specific ids.
required: false
schema:
type: array
items:
type: integer
description: Limit result set to specific ids.
- name: offset
in: query
description: Offset the result set by a specific number of items.
required: false
schema:
type: integer
description: Offset the result set by a specific number of items.
- name: order
in: query
description: Order sort attribute ascending or descending.
required: false
schema:
type: string
description: Order sort attribute ascending or descending.
enum:
- asc
- desc
- name: orderby
in: query
description: Sort collection by object attribute.
required: false
schema:
type: string
description: Sort collection by object attribute.
enum:
- date
- id
- include
- title
- slug
- modified
- popularity
- rating
- popularity
- rating
- menu_order
- price
- popularity
- rating
- name: parent
in: query
description: Limit result set to those of particular parent IDs.
required: false
schema:
type: array
items:
type: integer
description: Limit result set to those of particular parent IDs.
- name: parent_exclude
in: query
description: >-
Limit result set to all items except those of a particular parent
ID.
required: false
schema:
type: array
items:
type: integer
description: >-
Limit result set to all items except those of a particular parent
ID.
- name: slug
in: query
description: Limit result set to products with a specific slug.
required: false
schema:
type: string
description: Limit result set to products with a specific slug.
- name: status
in: query
description: Limit result set to products assigned a specific status.
required: false
schema:
type: string
description: Limit result set to products assigned a specific status.
enum:
- any
- future
- trash
- draft
- pending
- private
- publish
- name: type
in: query
description: Limit result set to products assigned a specific type.
required: false
schema:
type: string
description: Limit result set to products assigned a specific type.
enum:
- simple
- grouped
- external
- variable
- name: sku
in: query
description: >-
Limit result set to products with specific SKU(s). Use commas to
separate.
required: false
schema:
type: string
description: >-
Limit result set to products with specific SKU(s). Use commas to
separate.
- name: featured
in: query
description: Limit result set to featured products.
required: false
schema:
type: boolean
description: Limit result set to featured products.
- name: category
in: query
description: Limit result set to products assigned a specific category ID.
required: false
schema:
type: string
description: Limit result set to products assigned a specific category ID.
- name: tag
in: query
description: Limit result set to products assigned a specific tag ID.
required: false
schema:
type: string
description: Limit result set to products assigned a specific tag ID.
- name: shipping_class
in: query
description: Limit result set to products assigned a specific shipping class ID.
required: false
schema:
type: string
description: >-
Limit result set to products assigned a specific shipping class
ID.
- name: attribute
in: query
description: >-
Limit result set to products with a specific attribute. Use the
taxonomy name/attribute slug.
required: false
schema:
type: string
description: >-
Limit result set to products with a specific attribute. Use the
taxonomy name/attribute slug.
- name: attribute_term
in: query
description: >-
Limit result set to products with a specific attribute term ID
(required an assigned attribute).
required: false
schema:
type: string
description: >-
Limit result set to products with a specific attribute term ID
(required an assigned attribute).
- name: on_sale
in: query
description: Limit result set to products on sale.
required: false
schema:
type: boolean
description: Limit result set to products on sale.
- name: min_price
in: query
description: Limit result set to products based on a minimum price.
required: false
schema:
type: string
description: Limit result set to products based on a minimum price.
- name: max_price
in: query
description: Limit result set to products based on a maximum price.
required: false
schema:
type: string
description: Limit result set to products based on a maximum price.
- name: include_meta
in: query
description: Limit meta_data to specific keys.
required: false
schema:
type: array
items:
type: string
description: Limit meta_data to specific keys.
- name: exclude_meta
in: query
description: Ensure meta_data excludes specific keys.
required: false
schema:
type: array
items:
type: string
description: Ensure meta_data excludes specific keys.
- name: stock_status
in: query
description: Limit result set to products with specified stock status.
required: false
schema:
type: string
description: Limit result set to products with specified stock status.
enum:
- instock
- outofstock
- onbackorder
- name: search_sku
in: query
description: Limit results to those with a SKU that partial matches a string.
required: false
schema:
type: string
description: Limit results to those with a SKU that partial matches a string.
/products/batch:
patch:
operationId: patchProductsBatch
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/batch' # Reference the batch schema
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/batch' # Reference the batch schema for the response
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/WPError' # Error handling schema
'404':
description: Not Found
tags:
- root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment