Getting Started

Assume you already tried API Explorer. Here is a basic sample for the LookupRequest. For FREE plan, just remove user_key, key_type from the request header and change the endpoint path from /v1 to /trial.

To use compression, include the HTTP header Accept-Encoding: gzip or Accept-Encoding: deflate in a request. The REST API compresses the response if the client properly specifies this header. The response includes the header Content-Encoding: gzip or Accept-Encoding: deflate.

Note: JSON format uses Double Quote \”.


$ curl -X POST -H "user_key: only_for_dev_or_pro" -H "key_type: 3scale" -H "Content-Type: application/json" -H "Accept: application/json" -H "Accept-Encoding: gzip, deflate" --compressed -d "{
  \"upc\": \"4002293401102\"
}" "https://api.upcitemdb.com/prod/v1/lookup"
    
  


#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Headers;
use LWP::Debug '+';

$user_key = 'only_for_dev_or_pro';
$endpoint = 'https://api.upcitemdb.com/prod/v1/lookup';

$ua = LWP::UserAgent->new;
# debug request/response
$ua->add_handler("request_send",  sub { shift->dump; return });
$ua->add_handler("response_done", sub { shift->dump; return });
$h = HTTP::Headers->new(
    Content_Type => 'application/json',
    Accept => 'application/json'
    );
#preserve underscore in header name
$HTTP::Headers::TRANSLATE_UNDERSCORE = 0;
$h->header("user_key" => $user_key);
$h->header("key_type" => '3scale');

$url = $endpoint . '?upc=650106303651';
$req = HTTP::Request->new('GET', $url, $h);
$resp = $ua->request($req);

if ($resp->is_success) {
    $msg = $resp->decoded_content;
    print "Resp: $message\n";
} else {
    print "Error " . $resp->code . ": " . $resp->message . "\n";
}
    
  


<?php
$user_key = 'only_for_dev_or_pro';
$endpoint = 'https://api.upcitemdb.com/prod/v1/lookup';

$ch = curl_init();
/* if your client is old and doesn't have our CA certs
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch,CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "user_key: $user_key",
  "key_type: 3scale",
  "Accept: application/json",
  "Accept-Encoding: gzip,deflate"
));

// HTTP GET
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, $endpoint.'?upc=4002293401102');
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode != 200)
  echo "error status $httpcode...\n";
else 
  echo $response."\n";
/* if you need to run more queries, do them in the same connection.
 * use rawurlencode() instead of URLEncode(), if you set search string
 * as url query param
 * for search requests, change to sleep(6)
 */
sleep(2);
// proceed with other queries
curl_close($ch);
    
  


import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Accept-Encoding': 'gzip,deflate',
  'user_key': 'only_for_dev_or_pro',
  'key_type': '3scale'
}
resp = requests.get('https://api.upcitemdb.com/prod/v1/lookup?upc=4002293401102', headers=headers)
data = json.loads(resp.text)
for item in data['items']:
  print("{}\t{}\t{}\t{}-{}".format(item['ean'], item['title'], item['brand'], item['lowest_recorded_price'], item['highest_recorded_price']))
  for offer in item['offers']:
    print("{}\t{}\t{}".format(offer['domain'], offer['title'], offer['price']))
    
  


require 'rest-client'
response = RestClient.post("https://api.upcitemdb.com/prod/v1/lookup",
  { 'upc' => '4002293401102' }.to_json,
  {
    :content_type => :json,
    :accept => :json,
    user_key => 'only_for_dev_or_pro',
    key_type => '3scale'
  }
)
puts "status: #{response.code}"
puts "----headers----"
puts response.headers
puts "----body----"
puts response
    
  


var request = require('request')
request.post({
    uri: 'https://api.upcitemdb.com/prod/v1/lookup',
    headers: {
      "Content-Type": "application/json",
      "user_key": "only_for_dev_or_pro",
      "key_type": "3scale"
    },
    gzip: true,
    body: "{ \"upc\": \"4002293401102\" }",
  }, function (err, resp, body) {
    console.log('server encoded the data as: ' + (resp.headers['content-encoding'] || 'identity'))
    console.log('the decoded data is: ' + body)
  }
)
    
  


using System;
using RestSharp;
using Newtonsoft.Json;
using Microsoft.CSharp;

namespace UpcClient
{
  class MainClass
  {
    public static void Main(string[] args)
    {
      var user_key = "only_for_dev_or_pro";

      var client = new RestClient("https://api.upcitemdb.com/prod/v1/");
      // lookup request with GET
      var request = new RestRequest("lookup", Method.GET);
      request.AddHeader("key_type", "3scale");
      request.AddHeader("user_key", user_key);

      request.AddQueryParameter("upc", "674785680773");
      IRestResponse response = client.Execute(request);
      Console.WriteLine("response: " + response.Content);
      // parsing json
      var obj = JsonConvert.DeserializeObject(response.Content);
      Console.WriteLine("offset: " + obj["offset"]);
    }
  }
}