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 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);
}
}