/product/{id}

Save a product to the database. This request does not count toward your API limit.


Definition

https://api.upcdatabase.org/product/{id}

Post Request

curl --location --request POST 'https://api.upcdatabase.org/product/1010101010104' \
--header 'Authorization: Bearer THISISALIVEDEMOAPIKEY19651D54X47' \
--header 'Content-Type: multipart/form-data; boundary=--------------------------915002207591134892666102' \
--form 'title=This is a test title' \
--form 'description=This is a longer, more detailed description of the product.' \
--form 'alias=Short title' \
--form 'brand=iPaad' \
--form 'manufacturer=Pineapple' \
--form 'asin=A1M2A3Z4O5N6' \
--form 'msrp=599.98' \
--form 'category=Phones' \
--form 'mpn=i_phone_mpn'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.upcdatabase.org/product/1010101010104",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array(
            'title' => 'This is a test title',
            'description' => 'This is a longer,
             more detailed description of the product.',
            'alias' => 'Short title',
            'brand' => 'iPaad',
            'manufacturer' => 'Pineapple',
            'asin' => 'A1M2A3Z4O5N6',
            'msrp' => '599.98',
            'category' => 'Phones',
            'mpn' => 'i_phone_mpn'
        ),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer THISISALIVEDEMOAPIKEY19651D54X47",
    "Content-Type: multipart/form-data; boundary=--------------------------915002207591134892666102"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response

{
    "success": true,
    "message": "Item added successfully.",
    "timestamp": 1585074274
}
{
    "success": false,
    "error": {
        "message": "Item already exists"
    },
    "timestamp": 1730618644}
{
    "success": false,
    "error": {
        "message": "The product title is too short."
    },
    "timestamp": 1585074664
}

Example PHP

$data = array(
    'title' => 'General Item Name',
    'alias' => 'ShortName',
    'description' => 'A sentence or two describing the item. It should cover the basics.',
    "brand" => "",
    "category" => "",
    "size" => "",
    "color" => "",
    "gender" => "",
    "age" => "",
    "msrp" => ""
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL, 'https://api.upcdatabase.org/product');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

var_dump($result);