API's for the diamond industry

Download Complete Lab Grown File

Overview: In this lab grown diamond feed API you will send an HTTP request with the requested identifiers in JSON, and you will get the full details of all filtered available diamonds back in a zipped CSV file. This service is available as an add-on to all subscribers of the IDEX trading platform, however, results may vary based on your subscription type and permissions. This feed will return all lab grown diamond listings available for onsite feeds from IDEX.

Input Parameters

Note: you must use a valid Api Key that provides access to this service and have an active subscription to this service.
Parameter Example Format Mandatory
api_key HNNSSA1223311 String Yes
api_secret DDccdaaedf123 String Yes
data_format This is the data template. This can be "format_lg_20221130".
String Yes

Data Formats

You should specify a data format for future compatibility.
format_lg_20221130
Headers: Item ID, Supplier Stock Ref, Cut, Carat, Color, Natural Fancy Color, Natural Fancy Color Intensity, Natural Fancy Color Overtone, Treated Color, Clarity, Cut Grade, Grading Lab, Certificate Number, Certificate URL, Image URL, Online Report URL, Polish, Symmetry, Price Per Carat, Total Price, Measurements Length, Measurements Width, Measurements Height, Depth, Table, Crown Height, Crown Angle, Pavilion Depth, Pavilion Angle, Girdle From, Girdle To, Culet Size, Culet Condition, Graining, Fluorescence Intensity, Fluorescence Color, Enhancement, Country Code, Country Name, State Code, State Name, Pair Stock Ref, Pair Separable, Asking Price Per Carat For Pair, Shade, Milky, Black Inclusion, Eye Clean, Provenance Report, Provenance Number, Brand, Availability, Video URL, 3DViewer URL

Note: Files are generated every hour. Country code are in ISO 3166-1 Alpha-3 format. State (region) codes are in ISO 3166-2 format with both country and state/region codes, e.g. US-NY.
Note: "Video URL" and "3DViewer URL" were added on June 20, 2023.

Sample Request

HTTP JSON
Endpoint: https://api.idexonline.com/onsite/api/labgrownfullfile
{
	"authentication_details":{
		"api_key":"HNNSSA1223311",
		"api_secret":"DDccdaaedf123"
	},
	"parameters":{
		"data_format": "format_lg_20221130"
	}
}
see similer postman setup.

Sample Response

File or JSON Data
If all goes well, the HTTP code will be 200. You will get the file
In case of an exception, the error message will be displayed in this format, and the HTTP code will be 500.
{
    "result_info": {
        "response_code": 32110,
        "response_description": "A description of the exception."
    }
}
		

Sample Code

C#
string endpoint = "https://api.idexonline.com/onsite/api/labgrownfullfile";
string reqJson = "";
string result = "";
bool error = false;
string downloadPath = @"C:\IDEX\Temp\Onsite\file.zip";
string errorPath = @"C:\IDEX\Temp\Onsite\file_error.txt";

reqJson = "{\"authentication_details\":{\"api_key\":\"yourapikey\",\"api_secret\": \"yourapisecret\"},";
reqJson += "\"parameters\":{\"data_format\": \"format_lg_20221130\"}}";

System.Net.WebRequest wr = System.Net.WebRequest.Create(endpoint);
wr.Method = "POST";
wr.ContentType = "application/json; charset=UTF-8";
wr.Timeout = 900000;
System.IO.Stream reqStream = wr.GetRequestStream();
byte[] postArray = System.Text.Encoding.UTF8.GetBytes(reqJson);
reqStream.Write(postArray, 0, postArray.Length);
reqStream.Close();

try
{
	System.Net.WebResponse webResponse = wr.GetResponse();

	if (webResponse.Headers["content-disposition"] != null)
	{
		//got a file
		System.IO.Stream s = webResponse.GetResponseStream();
		if (System.IO.File.Exists(downloadPath))
		{
			System.IO.File.Delete(downloadPath);
		}

		//save file:
		using (System.IO.FileStream os = new System.IO.FileStream(downloadPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
		{
			byte[] buff = new byte[102400];
			int c = 0;
			while ((c = s.Read(buff, 0, 10400)) > 0)
			{
				os.Write(buff, 0, c);
				os.Flush();
			}
			os.Close();
			s.Close();
		}
			
	}
	else
	{
		//didn't get a file, will be json with error message.
		System.IO.StreamReader sr = new System.IO.StreamReader(webResponse.GetResponseStream());
		result += sr.ReadToEnd();
		error = true;
	}

}
catch (System.Net.WebException ex)
{
	//unexpected error (500):
	System.IO.StreamReader sr = new System.IO.StreamReader(ex.Response.GetResponseStream());
	result = ex.Status.ToString();
	result += sr.ReadToEnd();
	error = true;
}

if (error == true)
{
	using (System.IO.StreamWriter writer = new System.IO.StreamWriter(errorPath))
	{
		writer.Write(result);
	}
}

© IDEX 2024, www.idexonline.com