Product Data Enrichment with Postman and JSON

For this guide, we're going to assume the following you're interested in using Datafiniti's product data enrichment to enrich an existing line-separated json file of gtin values. There are 5 steps to run a product data enrichment using json:

  1. Select your enrichment file
  2. Set your field_parameter(s)
  3. Configure your query
  4. Configure your format & view
  5. Start your download

Select your enrichment file

Shown here is an example of an acceptable line separate json file with the correct keys to match gtins. We will be using this file for the example.

{"id":"ByfmlncBccoD1xujZi_h","brand":"DELL","gtins":884116385257}
{"id":"NSvlJ3gBUbef_7uTmrZ0","brand":"iVIEW","gtins":880010018154}
{"id":"AW5IbZIW0Rejpz6vwAXt","brand":"DELL","gtins":884116316909}
{"id":"dgiPbXIBvxj1aRneT4Do","brand":"Lenovo","gtins":194552049454}
{"id":"AVwjfl5Pnnc1JgDc5uVT","brand":"Microsoft","gtins":"0889842170634"}
{"id":"b1HdPnIBo6SyyXo05RFA","brand":"HP","gtins":195122090630}
{"id":"ufzNCHUBo6SyyXo0Cbhh","brand":"HP","gtins":880118668855}
{"id":"V3Lmn3IBo6SyyXo08van","brand":"Lenovo","gtins":194778022286}
{"id":"hiblJ3gBPkqI1fUQnVR3","brand":"iVIEW","gtins":880010018116}
{"id":"DYxQZXEBPkqI1fUQQmtB","brand":"Microsoft","gtins":889842294590}
{"id":"F-ej_3EBvxj1aRneqIxF","brand":"Microsoft","gtins":889842594003}
{"id":"5u9xbHYBUbef_7uTUCwb","brand":"ASUS","gtins":192876840085}
{"id":"cQrmQHcBPkqI1fUQlT3h","brand":"HP","gtins":196068441692}
{"id":"AV13Ck1nglJLPUi8O7f5","brand":"HP","gtins":"0825633419421"}
{"id":"HBCgGXcBvxj1aRneekAa","brand":"Lenovo","gtins":195477750357}
{"id":"wYybZHEBPkqI1fUQJCDZ","brand":"Microsoft","gtins":889842388244}
{"id":"kiw2NXMBPkqI1fUQQYJW","brand":"Microsoft","gtins":889842265903}
{"id":"l_E3AngBYEtaI8J07_Y-","brand":"ASUS","gtins":192876803684}
{"id":"AW-1PyF-0Rejpz6vIIv6","brand":"Microsoft","gtins":889842784145}
{"id":"AVpe8Qmu1cnluZ0-aV3y","brand":"HP","gtins":680596404057}

Set your enrichment file as the field_parameter file.

1431

Set your field_parameter

For the field parameter, we want to make sure that the Datafiniti schema field is selected and matches inside the txt file. This will allow the enrichment API to target submitted gtins in our case here.

1615

🚧

Line separate json file

Our enrichment search API will not allow a regular json file as submittable comparison file. Please be sure to convert you json to a line separated file before submission. Common error you may see in this case:

    "Invalid file type, must be csv or text file."

Configure your query

The query is essential to target the specific group of data you are trying to enrich from. Datafiniti has a very large dataset, and in most cases, you will not need to search through the entire database. Your query can be built using the same logic from our search API here.

There are some things you must have in your query. You must include a wildcard for each of the field_parameter you are search off of. In this case, we will add the following:

For our example here, we will add logic to our query to search for categories equal to cosmetics and only for products updated since September 31st

gtins:* AND categories:cosmetics AND dateUpdated:[2022-09-31 TO *]
1599

🚧

Query - download time

We strongly advise against generalized field_parameter values. This will create a search through a larger pool of products. Therefore the more specific your query is, the faster your enrichment job will be.

Configure your format & view

Your format will determine the output file type of the enrichment download you wish to start. This can be set to either of csv or json. For this example we will set it to csv.

Finally the view is used to specify which fields you want added to your data. If no view is provided, we will add all fields from matching records as we do for our default view for the product search API.

Your finally parameter should be setup as the following.

1599

Listed below is a cURL POST to import this example into Postman.

curl --location --request POST 'https://api.datafiniti.co/v4/product/search/enrichment' \
--header 'Authorization: Bearer replace_with_your_APIkey' \
--form 'gtins=@"/C:/Users/Leonard/Downloads/productEnrichment20.txt"' \
--form 'format="csv"' \
--form 'num_records="20"' \
--form 'query="gtins:* AND categories:comestics AND dateUpdated[2022-09-31 TO *]"' \
--form 'view=""'

Start your download

Once you send your Postman request for the enrichment download you will not be charged credits immediately. It will create a download response. We recommend holding on to the download ID for that will allow your to access the data once the status is complete. For more on how to manage your downloads, you can visit here.

An example enrichment download response:

"status": "completed",
    "num_downloaded": 19,
    "num_records_suppressed": 0,
    "total_cost": 19,
    "sort": true,
    "format": "json",
    "suppressed_fields": [],
    "enriched_fields": [
        {
            "field": "gtins",
            "s3Key": "production/126609/1665067765258-productEnrichment20.txt"
        }
    ],
    "_id": 185115,
    "user": 126609,
    "query": "name:(laptop) AND taxonomy:* AND gtins:* AND taxonomyLevel3:\"computers & tablets\"",
    "num_records": 20,
    "data_type": "product",
    "results": [
        "https://datafiniti-downloads.s3.amazonaws.com/126609/185115_1.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221006T151736Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=AKIAZSCI425AD5EKHVNH%2F20221006%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=e35aaeaf9e192a7e6009ef83c18502da154b61e546cef7540528b6ce12af1d81"
    ],
    "date_started": "2022-10-06T14:49:25.857Z",
    "date_updated": "2022-10-06T15:17:36.726Z",
    "is_suppression_job": false,
    "is_enrichment_job": true,
    "id": "185115"

🚧

Credit usage

Please note the number of num_record will not be charged to your account upon submitting this request. You will only be charged credits per record matched. Since enrichment charges credits per the batch file you are enriching data from, you may be overcharged credits to your account upon submitting an enrichment request. If you do not know if overcharging is enabled / disabled on your account you may contact [email protected] to find this info out.