Instant Inventory

Overview

RapNet Instant Inventory enables you to showcase thousands of diamonds or jewelry items from RapNet’s global suppliers on your website as a virtual store.
You can place a diamond feed on one page of your website and a jewelry feed on another page of your website. 

Instant Inventory is a live feed, therefore, all inventory is maintained by RapNet and changes reflect automatically in your Instant Inventory store. 

We offer 2 integration methods:

  1. RapNet’s pre-designed search engine widget
  2. An API that enables you to customize and build your own search engine

Note: 

  • Most e-commerce platforms are compatible with Instant inventory, for example, WordPress, Woo Commerce, Wix, and  Shopify.
  • RapNet Instant Inventory is only accessible with a paid RapNet subscription.
  • Please contact RapNet Customer Service to verify that your current subscription includes an Instant Inventory add-on. 

Important: You are not permitted to download diamond data and/or import RapNet diamonds into your database. 

Instant Inventory Setup

To set up, members choose diamonds and/jewelry they want on their site,  select suppliers to work with, and mark up the price to display in the store. 

Requirements

  1. Set up your feed for Instant Inventory 
  2. Select the diamonds or jewelry you want to display  
  3. Select your suppliers 
  4. Choose the markup you want to use 
  5. Set up an access key for the developer or tech team to access data and work on integration

Instant Inventory Integration

Once you have set up your Instant Inventory feeds, integrate using either the pre-designed widget or API. 

  1. RapNet pre-designed widget:
    • Is available for both diamond and jewelry feeds 
    • Is web and mobile-friendly 
    • Offers some customizable features 
    • Integrates into your website quickly and easily using the script provided
    •  The script is in HTML so you may need a 3rd party web developer to help with integration

  2. API Integration
    • Available for the diamond feed only 
    • Gives you more freedom, whereby you can design your own website, build your own diamond search engine, offer multiple currencies, languages 
    • Is ideal if you have existing e-commerce and shopping cart applications.


Important:

  • We recommend that you talk to your website developer for assistance.   
  • There is currently no add-to-cart or API option for instant inventory jewelry. 

API Integration Setting Requirements

  • Authentication: Each request must have a username and password
  • Request method: All requests should be sent using POST 
  • Content-Type: Application/x-www-form-urlencoded 
  • URL: Encode the request
  • Optional values: Can be omitted or left blank 
  • Response: The response will always contain an “error code” field:   
    • If the error code field value is 0, the operation succeeded 
    • If the error code field value is not 0, you will need to check your code or contact Tech Support. 

Click here to generate your own sample code. 

Sample Codes

Links to API codes

Instant Inventory Diamonds Search Sample Code

Required Fields

Code

Parameters Details Mandatory\ optional
username
Example : "myusername"

mandatory

password
Example : "mypassword"

mandatory

search_type
Allowed values : "White", "Fancy"

optional

 default is "White" .

shapes
Allowed values : "Round", "Pear",
"Princess", "Marquise", "Oval",
"Radiant", "Emerald", "Heart",
"Cushion", "Asscher"

optional

color_from
color_to
Allowed values : "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M"
optional
size_from
size_to
Example: 2.10
optional
fancy_colors
Allowed values :
"Yellow","Pink","Orange","Green",
"Gray", "Brown","Blue",
"Black","Red","Purple","Violet","
Champagne","Cognac","Chameleon"
optional
fancy_color_intensity_from fancy_color_intensity_to
Allowed values : "Faint","Very Light","Light","Fancy Light", "Fancy Dark", "Fancy Intense","Fancy Vivid", "Fancy Deep"
optional
clarity_from clarity_to
Allowed values : "IF", "VVS1", "VVS2", "VS1", "VS2", "SI1", "SI2", "SI3", "I1","I2","I3"
optional
cut_from cut_to
optional Allowed values : "Excellent", "Very Good", "Good", "Fair", "Poor"
optional
polish_from polish_to
Allowed values : "Excellent", "Very Good", "Good", "Fair", "Poor"
optional
symmetry_from symmetry_to
Allowed values : "Excellent", "Very Good", "Good", "Fair", "Poor"
optional
price_total_from price_total_to
Example : 100000
optional
labs
Allowed values : "GIA", "IGI", "AGS", "HRD", "PGS", "DCLA", "VGR", "GCAL","NGTC", "GSI", "DBGIS", "NONE"
optional
fluorescence_intensities
Allowed values : "Very Slight", "Faint", "Medium", "Slight", "Strong", "Very Strong","None"
optional
fluorescence_colors
Allowed values : "Blue", "Yellow", "Green", "Red", "Orange", "White"
optional
depth_percent_from depth_percent_to
Example : 66.7
optional
table_percent_from table_percent_to
Example : 54.2
optional
meas_length_from meas_length_to
Example : 6.41
optional
meas_width_from meas_width_to
Example : 3.91
optional
meas_depth_from meas_depth_to
Example : 3.12
optional
girdle_min girdle_max
Allowed values : "Extr Thin", "Very Thin", "Thin", "Slightly Thin", "Medium", "Slightly Thick", "Thick", "Very Thick", "Extr Thick"
optional
culet_sizes
Allowed values : "Very Small", "Small", "Medium", "Large"
optional
eye_cleans
Allowed values : "Yes", "Borderline", "No"
optional
page_number
Example : 1
mandatory
page_size
Example : 20
mandatory
sort_by
Allowed values : "Price","Shape","Size","Color", "Clarity", "Cut","Lab"
optional
sort_direction
Allowed values : "Asc","Desc"
optional
Code
				
					POST /HTTP/JSON/RetailFeed/GetDiamonds.aspx HTTP/1.1
Host: technet.rapaport.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 637


{
"request": {
"header": {
"username": " ", 
"password": ""

}, 
"body": {
"search_type": "White", 
"shapes": ["round","Princess","pear"], 
"size_from": 0.2, 
"size_to": 15.3, 
"color_from": "D", 
"color_to": "K", 
"clarity_from": "IF", 
"clarity_to": "VS2", 
"cut_from": "Excellent", 
"cut_to": "Fair", 
"polish_from": "Excellent", 
"polish_to": "Fair", 
"symmetry_from": "Excellent", 
"symmetry_to": "Fair", 
"price_total_from": 100, 
"price_total_to": 150000, 
"labs": ["GIA","IGI"], 
"table_percent_from": "26.0", 
"table_percent_to": "66.0", 
"page_number": 1, 
"page_size": 20, 
"sort_by": "price", 
"sort_direction": "Asc" 
}
}
}
				
			
Response
				
					{
"response": {
"header": {
"error_code": 0,
"error_message": ""
},
"body": {
"search_results": {
"diamonds_returned": 20,
"total_diamonds_found": 41,
"sorted_by" :"PRICE",
"sort_direction": "ASC"
},
"diamonds": [
{
"diamond_id": 135010171,
"shape": "Round",
"size": 5,
"color": "",
"fancy_color_dominant_color": "Brown",
"fancy_color_secondary_color": "",
"fancy_color_overtone": "",
"fancy_color_intensity": "Light",
"clarity": "SI1",
"cut": "Very Good",
"symmetry": "Excellent",
"polish": "Excellent",
"depth_percent": 64.4,
"table_percent": 58,
"meas_length": 10.68,
"meas_width": 10.71,
"meas_depth": 6.89,
"girdle_min": "M",
"girdle_max": "TK",
"girdle_condition": "",
"culet_size": "",
"culet_condition": "Pointed",
"fluor_color": "Blue",
"fluor_intensity": "Medium",
"has_cert_file": true,
"lab": "GIA",
"currency_code": "CAD",
"currency_symbol": "CAD$",
"total_sales_price": 37225,
"total_sales_price_in_currency": 47953,
"cert_num": "6223213479",
"stock_num": "JFG-1520",
"has_image_file": false,
"image_file_url": "",
"video_url": "",
"has_sarineloupe": false,
"eye_clean": ""
},
				
			

Instant Inventory Get Diamond Sample Code

Diamond_ID This is the diamond Id that is generated from the Search above

Single diamond code
				
					POST /HTTP/JSON/RetailFeed/GetSingleDiamond.aspx HTTP/1.1
Host: technet.rapaport.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 104

{
"request": {
"header": {
"username": "", 
"password": ""

}, 
"body": {
	"diamond_id": 41578579 
}
}
}
				
			
Response
				
					
{
"response": {
"header": {
"error_code": 0,
"error_message": ""
},
"body": {
"diamond": {
"diamond_id": 118134969,
"shape": "Round",
"size": 0.2,
"color": "H",
"fancy_color_dominant_color": "",
"fancy_color_secondary_color": "",
"fancy_color_overtone": "",
"fancy_color_intensity": "",
"clarity": "I1",
"cut": "Good",
"symmetry": "Good",
"polish": "Very Good",
"depth_percent": 61.8,
"table_percent": 58,
"meas_length": 3.68,
"meas_width": 3.71,
"meas_depth": 2.35,
"girdle_min": "M",
"girdle_max": "STK",
"girdle_condition": "",
"culet_size": "N",
"culet_condition": "",
"fluor_color": "",
"fluor_intensity": "None",
"has_cert_file": true,
"country": "",
"city": "",
"lab": "NONE",
"currency_code": "CAD",
"currency_symbol": "CAD$",
"cert_num": "",
"stock_num": "2559",
"video_url": "",
"has_sarineloupe": false,
"sarineloupe_url": "",
"has_imagefile": false,
"has_image_file": false,
"imagefile_url": "",
"total_purchase_price": 68,
"total_sales_price": 96,
"total_sales_price_in_currency": 122
},
"seller": {
"account_id": 12345,
"company": "Rapaport",
"name": "Mr Rapaport",
"email": "Help@diamonds.net",
"phone": "",
"country": "USA",
"state": "NJ",
"city": "Teaneck"
}
}
}
}
				
			
PHP XML Sample code
				
					<?php


 $client = new SoapClient("https://technet.rapaport.com/WebServices/RetailFeed/Feed.asmx?WSDL", 
      array( "trace" => 1, "exceptions" => 0, "cache_wsdl" => 0) ); 
 
$params = array('Username'=>'username', 'Password'=>'password); 
$client->__soapCall("Login", array($params), NULL, NULL, $output_headers); 
 
$ticket = $output_headers["AuthenticationTicketHeader"]->Ticket; 
 
$client1 = new SoapClient("https://technet.rapaport.com/WebServices/RetailFeed/Feed.asmx?WSDL", array( "trace" => 1, "exceptions" => 0, "cache_wsdl" => 0) ); 
 
$ns = "http://technet.rapaport.com/"; 
$headerBody = array("Ticket" => $ticket); 
$header = new SoapHeader($ns, 'AuthenticationTicketHeader', $headerBody); 
$client1->__setSoapHeaders($header); 
 
$searchParams = array( 
"ShapeCollection" => array("ROUND", "PEAR"), 
"LabCollection" => array("GIA"), 
"ColorFrom" => "D", 
"ColorTo" => "J", 
"ClarityFrom" => "IF", 
"ClarityTo" => "I1", 
"SizeFrom" => "0.3", 
"SizeTo" => "1.5", 
"CutFrom" => "EXCELLENT", 
"CutTo" => "GOOD", 
"GirdleSizeMin" => "EXTR_THICK", 
"GirdleSizeMax" => "SLIGHTLY_THICK", 
"TablePercentFrom" => "48.2", 
"TablePercentTo" => "73.4", 
"DepthPercentFrom" => "33.86", 
"DepthPercentTo" => "73.8", 
"MeasLengthFrom" => "3.7", 
"MeasLengthTo" => "6.4", 
"MeasWidthFrom" => "2.8", 
"MeasWidthTo" => "7.9", 
"MeasDepthFrom" => "2.7", 
"MeasDepthTo" =>"3.86", 
"PriceFrom" => "1", 
"PriceTo" => "999999", 
"PageNumber" => 1, 
"PageSize" => 25, 
"SortDirection" => "ASC", 
"SortBy" => "PRICE" 
); 
 
 
$params1 = array("SearchParams" => $searchParams, "DiamondsFound" => 0); 
$results=$client1->__soapCall("GetDiamonds", array($params1), NULL, NULL, $output_headers); 
 
//You can improve performance by making the first login request over HTTPS, like above, and the second request to get the diamonds over HTTP. 
 
echo '

Result diamonds
'; 
print_r($results); 
 
?> 
				
			

Add to Cart Integration

Programmers need to integrate code in order for the Add to Cart button to function.
They must first create the product in the e-commerce platform inventory and then save the output to the platform inventory.
As well as the sample code below, please also read this article for a full understanding of the Add to Cart integration.

Add to Cart integration
				
					<script type="text/javascript">

(function(d, w) {
function observeAddToCart() {
jQuery(w).on('ds.addtocart', function(event, data) {
jQuery.ajax({
//This is the API to where to POST the data to.
url: '/api/add_to_inventory_and_add_to_cart',
type: 'POST',
data: data
}).done(function(res) {
//On success of the API call
w.location = '/success';
}).fail(function(res) {
//On fail of the API call
alert(res.message);
});
});
}
if (d.addEventListener) {
d.addEventListener('ds.ready', function() {
observeAddToCart();
}, false);
} else if (d.attachEvent) {
d.documentElement.attachEvent('onpropertychange', function(event) {
if (event.propertyName === 'ds.ready')
observeAddToCart();
});
}
}(document, window));

</script>
				
			

 


<script type=”text/javascript”>
(function(d, w) {
function observeAddToCart() {

// console.error(‘TRIGGER’);

window.addEventListener(
‘ds.addtocart’,
ev => {
// console.log(‘!!!’, JSON.stringify(ev.detail.diamond, null, 2));
jQuery.getJSON(‘/products/’+ ev.detail.diamond.id +’.js’, function(product, status, xhrr) {
console.log(`product = ${JSON.stringify(product, null, 2)}`);
ev.detail.diamond[`shopify_product_id`] = product.id;
jQuery.post(‘https://example@example.com/createProduct’, ev.detail.diamond, function(data){
console.log(`data = ${JSON.stringify(data)}`);
var productJSON = [{
quantity: 1,
id: product.variants[0].id,
properties: {
Colour: ev.detail.diamond.color.color,
Clarity: ev.detail.diamond.clarity,
Shape: ev.detail.diamond.shape,
Polish: ev.detail.diamond.polish,
Cut: ev.detail.diamond.cut
}
}];
console.log(`productJSON = ${JSON.stringify(productJSON)}`);
var xhr = new XMLHttpRequest();
xhr.open(“POST”, ‘/cart/add.js’, true);
xhr.setRequestHeader(‘Content-Type’, ‘application/json’);
xhr.send(JSON.stringify({
items: productJSON}))
xhr.onload = function(res) {
jQuery(‘body’).trigger(‘added.ajaxProduct’);
};
})

}).fail(function(err){
if(err.status == 404) {
$(“#overlay”).fadeIn(300); 
jQuery.post(‘https://example@example.com/createProduct’, ev.detail.diamond, function(data){
console.log(`data = ${JSON.stringify(data)}`);
var productJSON = [{
quantity: 1,
id: parseInt(data.id.replace(“gid://shopify/ProductVariant/”,””)),
properties: {
Colour: ev.detail.diamond.color.color,
Clarity: ev.detail.diamond.clarity,
Shape: ev.detail.diamond.shape,
Polish: ev.detail.diamond.polish,
Cut: ev.detail.diamond.cut
}
}];
console.log(`productJSON = ${JSON.stringify(productJSON)}`);
var xhr = new XMLHttpRequest();
xhr.open(“POST”, ‘/cart/add.js’, true);
xhr.setRequestHeader(‘Content-Type’, ‘application/json’);
xhr.send(JSON.stringify({
items: productJSON}))
xhr.onload = function(res) {
$(“#overlay”).fadeOut(300);
jQuery(‘body’).trigger(‘added.ajaxProduct’);
};
})
.fail(function(err){
console.log(`err = ${JSON.stringify(err)}`);
})
}
})
}
);

// window.document.addEventListener(‘ds.addtocart’, e => {
// console.error(‘!!!+++’);
// });
}
if (d.addEventListener) {
d.addEventListener(‘ds.ready’, function() {
// console.error(‘2222’);
observeAddToCart();
}, false);
} else if (d.attachEvent) {
d.documentElement.attachEvent(‘onpropertychange’, function(event) {
if (event.propertyName === ‘ds.ready’)
observeAddToCart();
});
}
}(document, window));


</script>

Understanding the Add to Cart code

This is an example of ‘Add to Cart’ code simplified.

  1. Create the product in the e-commerce platform inventory (ie. Shopify/Magento etc) by creating an event listener. This is the event listener code:
    window.addEventListener(

    ‘ds.addtocart’,

  2. Save the output to platform inventory: In our example, the developer uses

    1. product.id to get all the diamond details: ev.detail.diamond[`shopify_product_id`] = product.id;

    2. Jquery code shown above to get details of the stones. Here’s what it looks like once you’ve pulled the data which the developer stores before posting on the website:

      jQuery.post(‘https://your-website.net/createProduct‘, ev.detail.diamond, function(data){

      console.log(`data = ${JSON.stringify(data)}`);

      var productJSON = [{

      quantity: 1,

      id: product.variants[0].id,

      properties: {

      Colour: ev.detail.diamond.color.color,

      Clarity: ev.detail.diamond.clarity,

      Shape: ev.detail.diamond.shape,

      Polish: ev.detail.diamond.polish,

      Cut: ev.detail.diamond.cut

      }

      }]

       

  3. Add a trigger to the details above. This is the trigger:

    console.log(`productJSON = ${JSON.stringify(productJSON)}`);

    var xhr = new XMLHttpRequest();

    xhr.open(“POST”, ‘/cart/add.js’, true);

    xhr.setRequestHeader(‘Content-Type’, ‘application/json’);

    xhr.send(JSON.stringify({

    items: productJSON}))

    xhr.onload = function(res) {

    jQuery(‘body’).trigger(‘added.ajaxProduct’);

    };

    })

     

  4. If the trigger is false, it will give this error code 404:

    }).fail(function(err){

    if(err.status == 404) {

    $(“#overlay”).fadeIn(300); 

    jQuery.post(‘https://example@example.net/createProduct’, ev.detail.diamond, function(data){

    console.log(`data = ${JSON.stringify(data)}`);

    var productJSON = [{

    quantity: 1,

    id: parseInt(data.id.replace(“gid://shopify/ProductVariant/”,””)),

    properties: {

    Colour: ev.detail.diamond.color.color,

    Clarity: ev.detail.diamond.clarity,

    Shape: ev.detail.diamond.shape,

    Polish: ev.detail.diamond.polish,

    Cut: ev.detail.diamond.cut

    }

    }];

    console.log(`productJSON = ${JSON.stringify(productJSON)}`);

    var xhr = new XMLHttpRequest();

    xhr.open(“POST”, ‘/cart/add.js’, true);

    xhr.setRequestHeader(‘Content-Type’, ‘application/json’);

    xhr.send(JSON.stringify({

    items: productJSON}))

    xhr.onload = function(res) {

    $(“#overlay”).fadeOut(300);

    jQuery(‘body’).trigger(‘added.ajaxProduct’);

    };

    })

    .fail(function(err){

    console.log(`err = ${JSON.stringify(err)}`);

    })

    }

    })

    }

    );

     

  5. If the trigger is true:

    // window.document.addEventListener(‘ds.addtocart’, e => {

    // console.error(‘!!!+++’);

    // });

    }

    if (d.addEventListener) {

    d.addEventListener(‘ds.ready’, function() {

    // console.error(‘2222’);

    observeAddToCart();

    }, false);

    } else if (d.attachEvent) {

    d.documentElement.attachEvent(‘onpropertychange’, function(event) {

    if (event.propertyName === ‘ds.ready’)

    observeAddToCart();

    });

    }

    }(document, window));

<script>

$(function() {
// Current Ajax request.
var currentAjaxRequest = null;
// Grabbing all search forms on the page, and adding a .search-results list to each.
var searchForms = $(‘form[action=”/search”]’).css(‘position’,’relative’).each(function() {
// Grabbing text input.
var input = $(this).find(‘input[name=”q”]’);
// Adding a list for showing search results.
var offSet = input.position().top + input.innerHeight();
$(‘<ul class=”search-results”></ul>’).css( { ‘position’: ‘absolute’, ‘left’: ‘0px’, ‘top’: offSet } ).appendTo($(this)).hide();
// Listening to keyup and change on the text field within these search forms.
input.attr(‘autocomplete’, ‘off’).bind(‘keyup change’, function() {
// What’s the search term?
var term = $(this).val();
// What’s the search form?
var form = $(this).closest(‘form’);
// What’s the search URL?
var searchURL = ‘/search?type=product&q=’ + term;
// What’s the search results list?
var resultsList = form.find(‘.search-results’);
// If that’s a new term and it contains at least 3 characters.
if (term.length > 3 && term != $(this).attr(‘data-old-term’)) {
// Saving old query.
$(this).attr(‘data-old-term’, term);
// Killing any Ajax request that’s currently being processed.
if (currentAjaxRequest != null) currentAjaxRequest.abort();
// Pulling results.
currentAjaxRequest = $.getJSON(searchURL + ‘&view=json’, function(data) {
// Reset results.
resultsList.empty();
// If we have no results.
if(data.results_count == 0) {
// resultsList.html(‘<li><span class=”title”>No results.</span></li>’);
// resultsList.fadeIn(200);
resultsList.hide();
} else {
// If we have results.
$.each(data.results, function(index, item) {
var link = $(‘<a></a>’).attr(‘href’, item.url);
link.append(‘<span class=”thumbnail”><img src=”‘ + item.thumbnail + ‘” /></span>’);
link.append(‘<span class=”type”>’ + item.type + ‘</span>’);
link.append(‘<span class=”title”>’ + item.title + ‘</span>’);
link.append(‘<span class=”price”>’ + item.price + ‘</span>’);
link.wrap(‘<li></li>’);
resultsList.append(link.parent());
});
// The Ajax request will return at the most 10 results.
// If there are more than 10, let’s link to the search results page.
if(data.results_count > 10) {
resultsList.append(‘<li><span class=”title”><a href=”‘ + searchURL + ‘”>See all results (‘ + data.results_count + ‘)</a></span></li>’);
}
resultsList.fadeIn(200);
}
});
}
});
});
// Clicking outside makes the results disappear.
$(‘body’).bind(‘click’, function(){
$(‘.search-results’).hide();
});
});

</script>
=====================================================================================================================================================


Add to cart page
<script>window.ShopifyAnalytics = window.ShopifyAnalytics || {};
window.ShopifyAnalytics.meta = window.ShopifyAnalytics.meta || {};
window.ShopifyAnalytics.meta.currency = ‘ZAR’;
var meta = {“page”:{“path”:”\/checkout\/contact_information”,”search”:”?_ga=2.47235943.1103702442.1622464711-71421577.1622464711″,”url”:”https:\/\/www.example.co.za\/27854504025\/checkouts\/011b1397d62d50f0909238b3161243c4?_ga=2.47235943.1103702442.1622464711-71421577.1622464711″},”page_view_event_id”:”df19d90a76727b8257d918a80466619bb8c928cbe7e8a4ec88715120b0858e01″,”cart_event_id”:”16723cbaed35a8f9e87a08df047446ec758681d9a6c758b6f2746a5a86d6c7e0″};
for (var attr in meta) {
window.ShopifyAnalytics.meta[attr] = meta[attr];
}</script>

Links & Help Articles

Accessibility