Skip to main content
GET
/
products
/
{id}
Get a product
curl --request GET \
  --url {protocol}://{host}/wp-json/cocart/v1/products/{id}
import requests

url = "{protocol}://{host}/wp-json/cocart/v1/products/{id}"

response = requests.get(url)

print(response.text)
const options = {method: 'GET'};

fetch('{protocol}://{host}/wp-json/cocart/v1/products/{id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/v1/products/{id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "{protocol}://{host}/wp-json/cocart/v1/products/{id}"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("{protocol}://{host}/wp-json/cocart/v1/products/{id}")
  .asString();
require 'uri'
require 'net/http'

url = URI("{protocol}://{host}/wp-json/cocart/v1/products/{id}")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
{
  "id": 123,
  "name": "<string>",
  "slug": "<string>",
  "permalink": "<string>",
  "date_created": "2023-11-07T05:31:56Z",
  "date_created_gmt": "2023-11-07T05:31:56Z",
  "date_modified": "2023-11-07T05:31:56Z",
  "date_modified_gmt": "2023-11-07T05:31:56Z",
  "type": "<string>",
  "status": "<string>",
  "featured": true,
  "catalog_visibility": "<string>",
  "description": "<string>",
  "short_description": "<string>",
  "sku": "<string>",
  "price": "<string>",
  "regular_price": "<string>",
  "sale_price": "<string>",
  "date_on_sale_from": "2023-11-07T05:31:56Z",
  "date_on_sale_from_gmt": "2023-11-07T05:31:56Z",
  "date_on_sale_to": "2023-11-07T05:31:56Z",
  "date_on_sale_to_gmt": "2023-11-07T05:31:56Z",
  "price_html": "<string>",
  "on_sale": true,
  "purchasable": true,
  "total_sales": 123,
  "virtual": true,
  "downloadable": true,
  "downloads": [
    {
      "id": "<string>",
      "name": "<string>",
      "file": "<string>"
    }
  ],
  "download_limit": 123,
  "download_expiry": 123,
  "external_url": "<string>",
  "button_text": "<string>",
  "tax_status": "<string>",
  "tax_class": "<string>",
  "manage_stock": true,
  "stock_quantity": 123,
  "stock_status": "<string>",
  "backorders": "<string>",
  "backorders_allowed": true,
  "backordered": true,
  "sold_individually": true,
  "weight": "<string>",
  "dimensions": {
    "length": "<string>",
    "width": "<string>",
    "height": "<string>"
  },
  "shipping_required": true,
  "shipping_taxable": true,
  "shipping_class": "<string>",
  "shipping_class_id": 123,
  "reviews_allowed": true,
  "average_rating": "<string>",
  "rating_count": 123,
  "related_ids": [
    123
  ],
  "upsell_ids": [
    123
  ],
  "cross_sell_ids": [
    123
  ],
  "parent_id": 123,
  "purchase_note": "<string>",
  "categories": [
    {
      "id": 123,
      "name": "<string>",
      "slug": "<string>"
    }
  ],
  "tags": [
    {
      "id": 123,
      "name": "<string>",
      "slug": "<string>"
    }
  ],
  "images": [
    {
      "id": 123,
      "src": "<string>",
      "name": "<string>",
      "alt": "<string>"
    }
  ],
  "attributes": [
    {
      "id": 123,
      "name": "<string>",
      "position": 123,
      "visible": true,
      "variation": true,
      "options": [
        "<string>"
      ]
    }
  ],
  "default_attributes": [
    {
      "id": 123,
      "name": "<string>",
      "option": "<string>"
    }
  ],
  "variations": [
    123
  ],
  "grouped_products": [
    123
  ],
  "menu_order": 123,
  "meta_data": [
    {
      "id": 123,
      "key": "<string>",
      "value": "<string>"
    }
  ],
  "links": {
    "self": [
      {
        "href": "<string>"
      }
    ],
    "collection": [
      {
        "href": "<string>"
      }
    ]
  }
}

Path Parameters

id
integer
required

Unique identifier for the product.

Query Parameters

context
enum<string>
default:view

Scope under which the request is made; determines fields present in response.

Available options:
view,
embed

Response

Product data.

id
integer

Unique identifier for the product.

name
string

Product name.

slug
string

Product slug.

Product URL.

date_created
string<date-time>

Date when the product was created.

date_created_gmt
string<date-time>

Date when the product was created in GMT.

date_modified
string<date-time>

Date when the product was last modified.

date_modified_gmt
string<date-time>

Date when the product was last modified in GMT.

type
string

Product type.

status
string

Product status.

Whether the product is featured.

catalog_visibility
string

Product catalog visibility.

description
string

Product description.

short_description
string

Product short description.

sku
string

Product SKU.

price
string

Product price.

regular_price
string

Product regular price.

sale_price
string

Product sale price.

date_on_sale_from
string<date-time>

Date when the sale price starts.

date_on_sale_from_gmt
string<date-time>

Date when the sale price starts in GMT.

date_on_sale_to
string<date-time>

Date when the sale price ends.

date_on_sale_to_gmt
string<date-time>

Date when the sale price ends in GMT.

price_html
string

Product price HTML.

on_sale
boolean

Whether the product is on sale.

purchasable
boolean

Whether the product is purchasable.

total_sales
integer

Total number of sales.

virtual
boolean

Whether the product is virtual.

downloadable
boolean

Whether the product is downloadable.

downloads
object[]
download_limit
integer

Download limit.

download_expiry
integer

Download expiry.

external_url
string

External URL.

button_text
string

Button text.

tax_status
string

Tax status.

tax_class
string

Tax class.

manage_stock
boolean

Whether stock management is enabled.

stock_quantity
integer

Stock quantity.

stock_status
string

Stock status.

backorders
string

Backorders status.

backorders_allowed
boolean

Whether backorders are allowed.

backordered
boolean

Whether the product is backordered.

sold_individually
boolean

Whether the product is sold individually.

weight
string

Product weight.

dimensions
object
shipping_required
boolean

Whether shipping is required.

shipping_taxable
boolean

Whether shipping is taxable.

shipping_class
string

Shipping class.

shipping_class_id
integer

Shipping class ID.

reviews_allowed
boolean

Whether reviews are allowed.

average_rating
string

Average rating.

rating_count
integer

Rating count.

Related product IDs.

upsell_ids
integer[]

Upsell product IDs.

cross_sell_ids
integer[]

Cross-sell product IDs.

parent_id
integer

Parent product ID.

purchase_note
string

Purchase note.

categories
object[]
tags
object[]
images
object[]
attributes
object[]
default_attributes
object[]
variations
integer[]

Variation IDs.

grouped_products
integer[]

Grouped product IDs.

menu_order
integer

Menu order.

meta_data
object[]