You may use GraphQL variables if you need data from a list of values for one or more attributes. Let's say you need to retrieve data with Brand A as well as Brand B. To accomplish this type of search, you'll want to loop through multiple calls to account for each value combination. Variables allow you to keep the query constant in each call and only change the variable inputs.

If you have a list of Regions and a list of NAICS Codes in those Regions to search, you may pass variables for Region and NAICS code in the query. You only need to change the Query Variables each time to cover the full list of value combinations.

query SearchByRegionAndNaics($region: String!, $naics: Int!) {
  search(filter: { 
    naics_code: $naics, 
    address: { 
        region: $region 
    } 
  }) 
{
    placekey
    safegraph_core {
      location_name
      top_category
      sub_category
      naics_code
    }
    safegraph_geometry {
      street_address
      region
      postal_code
      polygon_wkt
    }
  }
}
curl --location --request POST 'https://api.safegraph.com/v1/graphql' \
--header 'apikey: {your-api-key}' \
--header 'content-type: application/json' \
--data-raw '{"query":"query SearchByRegionAndNaics($region: String! $naics: Int!){\n  search(filter: { \n    naics_code: $naics\n    address: {\n      region: $region\n    }\n  })\n{\n    placekey\n    safegraph_core{\n      location_name\n      top_category\n      sub_category\n      naics_code\n    }\n    safegraph_geometry{\n      street_address\n      region\n      postal_code\n    \tpolygon_wkt\n    }\n  }\n}","variables":{"region":"IL","naics":445291}}'
# pip install safegraphQL
import safegraphql.client as sgql

sgql_client = sgql.HTTP_Client(apikey = 'your-api-key')

naics = 445291
region = 'IL'
core_cols = [
    'location_name',
    'top_category',
    'sub_category',
    'naics_code'
]
geom_cols = [
    'street_address',
    'region',
    'postal_code',
    'polygon_wkt'
]
core = sgql_client.search(product = 'core', region = region, naics_code = naics, columns = core_cols)
geometry = sgql_client.search(product = 'geometry', region = region, naics_code = naics, columns = geom_cols)

sgql_client.sg_merge(datasets = [core, geometry])
{
  "region": "IL",
  "naics": 445291
}
{
  "data": {
    "search": [
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Mrs. Fields Gifts",
          "top_category": "Specialty Food Stores",
          "sub_category": "Baked Goods Stores",
          "naics_code": 445291
        },
        "safegraph_geometry": {
          "street_address": "25W 420 Geneva Rd",
          "region": "IL",
          "postal_code": "60189",
          "polygon_wkt": "POLYGON ((-88.12184880799998 41.888124908000066, -88.12193885299996 41.88812247000004, -88.12195209699996 41.888387747000024, -88.12186205099994 41.88839018600004, -88.12184880799998 41.888124908000066))"
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Mrs. Fields Gifts",
          "top_category": "Specialty Food Stores",
          "sub_category": "Baked Goods Stores",
          "naics_code": 445291
        },
        "safegraph_geometry": {
          "street_address": "149 E Ogden Ave",
          "region": "IL",
          "postal_code": "60521",
          "polygon_wkt": "POLYGON ((-87.92640568399997 41.81645935000006, -87.92647352999995 41.816423359000055, -87.92656365899995 41.81651569700006, -87.92614614499996 41.81673717500007, -87.92607479299994 41.81666407500006, -87.92642446099995 41.81647858700006, -87.92640568399997 41.81645935000006))"
        }
      },
      
      .....
      
      },
  "extensions": {
    "row_count": 20,
    "version_date": "1627739802__2021_07"
  }
}