Javascript
Use our client library on Github ยป
Try it yourself
Hover over the top right of the code block to copy the code
What Lists are in the chem api?
Use this example to retrieve the set of lists within the chem api
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
//set base address
url:"https://sandbox.chemadvisor.io/chem/rest/v2/regulatory_lists",
type:'GET',
//set limit, offset
data:{
limit:10,
offset:0,
},
headers:{
//set accept header:'application/json', 'application/xml'
Accept:'application/json',
//set app_key header
app_key:'your_app_key',
//set app_id header
app_id:'your_app_id'
},
success: function(data){
//getting JSON data
alert(JSON.stringify(data));
<!-- //getting XML data -->
<!-- alert((new XMLSerializer()).serializeToString(data)); -->
},
error: function(error){
alert(JSON.stringify(error));
}
});
});
})
</script>
</head>
<body>
<button>Send an HTTP GET request to LOLI Rest Api</button>
</body>
</html>
What Tags are used on Lists within the chem api?
Use this example to retrieve the set of Tags within the chem api
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
//set base address
url:"https://sandbox.chemadvisor.io/chem/rest/v2/tags",
type:'GET',
//set limit, offset
data:{
limit:10,
offset:0,
},
headers:{
//set accept header:'application/json', 'application/xml'
Accept:'application/json',
//set app_key header
app_key:'your_app_key',
//set app_id header
app_id:'your_app_id'
},
success: function(data){
//getting JSON data
alert(JSON.stringify(data));
<!-- //getting XML data -->
<!-- alert((new XMLSerializer()).serializeToString(data)); -->
},
error: function(error){
alert(JSON.stringify(error));
}
});
});
})
</script>
</head>
<body>
<button>Send an HTTP GET request to LOLI Rest Api</button>
</body>
</html>
The power of the 'q'
The 'q' query parameter can be used within a supporting call to search any field within the resource. 'q' supports most of the syntax used by MongoDB db.find()
How do I find the Substance Id (_id) for CAS 50-00-0?
You can use 'q' to lookup a Substance Id (_id) by any Identifier that we support. Some of the Identifiers we support, but are not limited to, are CAS, EC, Annex, ENCS, and Formula
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
//set base address
url:"https://sandbox.chemadvisor.io/chem/rest/v2/substances",
type:'GET',
//set query parameters:q, limit, offset
data:{
limit:10,
offset:0,
q:encodeURI('{"identifiers.identifier.value": "50-00-0"}')
},
headers:{
//set accept header:'application/json', 'application/xml'
Accept:'application/json',
//set app_key header
app_key:'your_app_key',
//set app_id header
app_id:'your_app_id'
},
success: function(data){
//getting JSON data
alert(JSON.stringify(data));
<!-- //getting XML data -->
<!-- alert((new XMLSerializer()).serializeToString(data)); -->
},
error: function(error){
alert(JSON.stringify(error));
}
});
});
})
</script>
</head>
<body>
<button>Send an HTTP GET request to LOLI Rest Api</button>
</body>
</html>
How do I find all of the Canada OEL Lists in the chem api?
Using 'q' to get a set of lists by a Tag or Tags
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
//set base address
url:"https://sandbox.chemadvisor.io/chem/rest/v2/regulatory_lists",
type:'GET',
//set query parameters:q, limit, offset
data:{
limit:10,
offset:0,
q:encodeURI('{$and: [{"tags.tag.name": "OEL"}, {"tags.tag.name": "Canada"}]}')
},
headers:{
//set accept header:'application/json', 'application/xml'
Accept:'application/json',
//set app_key header
app_key:'your_app_key',
//set app_id header
app_id:'your_app_id'
},
success: function(data){
//getting JSON data
alert(JSON.stringify(data));
<!-- //getting XML data -->
<!-- alert((new XMLSerializer()).serializeToString(data)); -->
},
error: function(error){
alert(JSON.stringify(error));
}
});
});
})
</script>
</head>
<body>
<button>Send an HTTP GET request to LOLI Rest Api</button>
</body>
</html>