Getting Started with the
Product Metadata GraphQL API

We are excited to introduce our GraphQL API, which has been developed to provide a streamlined and efficient way to access MCR Safety product data. Our API offers a flexible and powerful interface, allowing you to retrieve the exact data you need in a single request. It is designed to be intuitive and easy to use, but we want to make it clear that the coding examples we provide are strictly for demonstration purposes only. As an API consumer, it is important for you to ensure that your application is coded to best practices and follows all security protocols to protect against potential vulnerabilities.

To get started you must first be onboarded and assigned a MCR Safety Integration Developer Key. If you do not have your key please email us at DigitalWeb@mcrsafety.com or see more information about connecting with us.

If you already have been assigned an Integration Developer Key, continue exploring the information below.

Once you have familiarized yourself with how to connect to MCR, we recommend reviewing the Product Metadata Attributes and Properties that are available. There are hundreds of product attributes, marketing description, product weights and dimensions available at your fingertips. Reviewing and knowing what's available allows you to consume only exactly what you need!

Obtain OAuth2 Token

Post URL: https://login.microsoftonline.com/676075e0-0ca6-4fe3-bbf2-b6c1e329aaeb/oauth2/v2.0/token

Body (x-www-form-urlencoded)

grant_type: client_credentials
client_id: {Given by MCR Resources}
client_secret: {Given by MCR Resources}
scope: 5e6cbd33-8277-4689-8652-ab7448bc5280/.default

CURL example

curl -X POST 'https://login.microsoftonline.com/676075e0-0ca6-4fe3-bbf2-b6c1e329aaeb/oauth2/v2.0/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials' \
-d 'client_id={Given by MCR Resources}' \
-d 'client_secret={Given by MCR Resources}' \
-d 'scope=5e6cbd33-8277-4689-8652-ab7448bc5280/.default'

Response

{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": {OAuth2 Token}
}

Calling API Endpoints

Post URL: https://connect.mcrsafety.com/product-metadata/v1

Headers

API-Key: {Given by MCR Resources}
Authorization: Bearer {OAuth2 Token}

Body (GraphQL)

{
products {
items {
productNumber
}
}
}

CURL example

curl -X POST 'https://connect.mcrsafety.com/product-metadata/v1' \
-H 'API-Key: {Given by MCR Resources}' \
-H 'Authorization: Bearer {OAuth2 Token}' \
-H 'Content-Type: application/json' \
-d '{"query":"{products{items{productNumber}}}"}'

Response

{
"data": {
"products": {
"items": [
{ "productNumber": "1003X5" },
{ "productNumber": "100GT" },
...
]
}
}
}

GraphQL Query Examples

Basic Example

With GraphQL, you have the flexibility to specify any property of the products you want (Learn about the Property Values).

In this basic example, the API will return get the first 100 products, along with their complete set of properties. The next example will demonstrate how to implement pagination using GraphQL. We recommend using pagination along with sorting to guarantee the order of the records.

Request Body                                                            Response
{ {
products { "data": {
items { "products": {
productNumber "items": [
productGroup {
productDescription "productNumber": "1500KM",
upc "productGroup": "02",
intermediateUPC "productDescription": "Sel shldr Leather Palm W/Kevlar",
caseUPC "upc": "30451431500217",
style "intermediateUPC": "045143150021",
countryOrigin "caseUPC": "10451431500213",
dateCreated "style": "1500K",
dateLastUpdated "countryOrigin": "CN",
measures { "dateCreated": "2005-10-18",
saleUOM "dateLastUpdated": "2023-01-01",
unitWeight "measures": {
unitWeightUOM "saleUOM": "DZ",
caseQTY "unitWeight": 6.372,
caseWeight "unitWeightUOM": "LB",
caseWeightUOM "caseQTY": 6,
caseLength "caseWeight": 38.232,
caseWidth "caseWeightUOM": "LB",
caseHeight "caseLength": 21.653,
caseDimensionUOM "caseWidth": 14.960,
minimumQTY "caseHeight": 18.897,
palletQTY "caseDimensionUOM": "IN",
unitLength "minimumQTY": 1,
unitWidth "palletQTY": 90,
unitHeight "unitLength": 10.236,
unitDimensionUOM "unitWidth": 5.511,
intermediateLength "unitHeight": 14.173,
intermediateWidth "unitDimensionUOM": "IN",
intermediateHeight "intermediateLength": null,
intermediateDimensionUOM "intermediateWidth": null,
intermediateWeight "intermediateHeight": null,
intermediateWeightUOM "intermediateDimensionUOM": "IN",
intermediateQTY "intermediateWeight": null,
} "intermediateWeightUOM": "LB",
attributes { "intermediateQTY": 1
key },
value "attributes": [
} {
marketingContents { "key": "ANSI Cut"
shortDescription "value": "A2"
detailedDescription },
marketingContent {
} // 2nd attribute data
features { },
featureText ...
} ]
} "marketingContents": {
pageInfo { "shortDescription": "Safety Gloves",
hasPreviousPage "detailedDescription": "Select shoulder...",
hasNextPage "marketingContent": "Hard workin'...",
} }
} "features": [
} {
"featureText": "Cotton canvas back"
},
{
// 2nd feature text
},
...
]
},
{
// 2nd product data
},
...
],
"pageInfo": {
"hasNextPage": true,
"hasPreviousPage": false
}
}
}
}

Pagination Example

In this example, you will skip the first 100 records and then retrieve the next 200 records. Each request allows a maximum 1000 records. To determine whether there are more records to retrieve, you can use pageInfo, which indicates whether there are next or previous pages available.

{
products (skip: 100 take: 200) {
items {
productNumber
attributes {
key
value
}
}

pageInfo {
hasNextPage
hasPreviousPage
}
}
}

Sorting Example

In this example, the products are sorted in ascending order by productNumber, while the attributes are sorted in descending order by their key.

{
products (order: { productNumber: ASC}) {
items {
productNumber
attributes (order: { key: DESC }) {
key
value
}
}
}
}

Filtering Examples

This example retrieves all products and their attributes that have a key-value pair of Chemical Resistant: Yes.

This the most complex scenario that allows you to specify exactly what you want. We recommend reviewing the Metadata Product Attributes & Values to familiarize yourself with the options and data points that are available.

{
products (
where: {
attributes: {
some: {
key: { eq: "Chemical Resistant" }
value: { eq: "Yes" }
}
}
}
) {
items {
productNumber
attributes {
key
value
}
}
}
}

This example retrieves all products and their attributes where the attributes have either Chemical Resistant or FDA Clearance as their key.

{
products (
where: {
attributes: {
some: {
key: {
or: [
{ eq: "Chemical Resistant" }
{ eq: "FDA Clearance" }
]
}
}
}
}
) {
items {
productNumber
attributes {
key
value
}
}
}
}

In this example, the first where clause retrieves all products and their attributes that have a key-value pair of Chemical Resistant: Yes. The second where clause then filters the results to only include the ANSI Cut attribute,

{
products (
where: {
attributes: {
some: {
key: { eq: "Chemical Resistant" }
value: { eq: "Yes" }
}
}
}
) {
items {
productNumber
attributes (
where: {
key: { eq: "ANSI Cut" }
}
) {
key
value
}
}
}
}
Picture

Are You Ready?

Be sure to explore the Attributes, Values, and Property values available for MCR Safety products.

See the property values