Skip to content

Schema (Filterable Columns) ​

The schema endpoint lets you discover which columns are available for filtering on any datatable-based endpoint. This is especially useful for building dynamic filters or working with the custom_filter parameter on endpoints like PPC.

GET /schema/get-filterable-columns ​

Returns the list of filterable columns for a given datatable, including column names, display titles, data types, and descriptions.

Parameters ​

NameTypeRequiredDescription
datatablestringYesDatatable identifier (see table below)
account_titlestringNoFilter by account title
seller_idstringNoAmazon seller ID (requires marketplace_id)
marketplace_idstringNoAmazon marketplace ID (requires seller_id)

Common Datatable Identifiers ​

DatatableUsed By
productsInventory, product listings
inventoryInventory list
ordersSales orders
ppc_sp_campaignsSP campaign data
ppc_sp_ad_groupsSP ad group data
ppc_sp_keywordsSP keyword data
ppc_sb_campaignsSB campaign data
ppc_sb_ad_groupsSB ad group data
ppc_sd_campaignsSD campaign data
ppc_sd_ad_groupsSD ad group data

Response ​

json
{
  "datatable": "ppc_sp_campaigns",
  "columns": [
    {
      "name": "impressions",
      "title": "Impressions",
      "type": "number",
      "description": "Impressions - Total number of ad impressions"
    },
    {
      "name": "campaign_name",
      "title": "Campaign Name",
      "type": "text",
      "description": "Campaign Name - The name of the campaign"
    },
    {
      "name": "state",
      "title": "State",
      "type": "select",
      "description": "State - Campaign state (enabled, paused, archived)"
    }
  ]
}

Column Types ​

TypeDescriptionFilter Conditions
textText fieldscontains, is, is_not, starts_with, ends_with, regexp
numberNumeric fields>, <, >=, <=, =, between
selectEnum/choice fieldsin, not_in
dateDate fieldsbetween, greater_than, less_than
boolBoolean fieldstrue, false

All types also support: is_null, not_null, is_empty.

Using custom_filter ​

Once you know the available columns, you can build custom_filter objects for endpoints that support them:

json
{
  "impressions": {
    "type": "number",
    "condition": ">",
    "value": 1000
  },
  "campaign_name": {
    "type": "text",
    "condition": "contains",
    "value": "Brand"
  }
}

Examples ​

python
import requests

headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}

# Discover filterable columns for SP campaigns
response = requests.get(
    "https://app.sellerlegend.com/api/schema/get-filterable-columns",
    headers=headers,
    params={
        "datatable": "ppc_sp_campaigns",
        "account_title": "My Store US"
    }
)

schema = response.json()
for col in schema["columns"]:
    print(f"{col['name']} ({col['type']}): {col['description']}")
php
$token = "YOUR_ACCESS_TOKEN";

$params = http_build_query([
    "datatable" => "ppc_sp_campaigns",
    "account_title" => "My Store US"
]);

$ch = curl_init("https://app.sellerlegend.com/api/schema/get-filterable-columns?{$params}");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$schema = json_decode(curl_exec($ch), true);
curl_close($ch);

foreach ($schema["columns"] as $col) {
    echo "{$col['name']} ({$col['type']}): {$col['description']}\n";
}
javascript
const response = await fetch(
  "https://app.sellerlegend.com/api/schema/get-filterable-columns?" + new URLSearchParams({
    datatable: "ppc_sp_campaigns",
    account_title: "My Store US"
  }),
  {
    headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN" }
  }
);

const schema = await response.json();
schema.columns.forEach(col => {
  console.log(`${col.name} (${col.type}): ${col.description}`);
});
bash
curl -G "https://app.sellerlegend.com/api/schema/get-filterable-columns" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d "datatable=ppc_sp_campaigns" \
  -d "account_title=My+Store+US"

Combining Schema with PPC Queries ​

A common workflow is to first discover available columns, then use them to filter PPC data:

python
import requests
import json

headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}
base_url = "https://app.sellerlegend.com/api"

# Step 1: Discover columns
schema = requests.get(
    f"{base_url}/schema/get-filterable-columns",
    headers=headers,
    params={"datatable": "ppc_sp_campaigns", "account_title": "My Store US"}
).json()

print("Available columns:", [c["name"] for c in schema["columns"]])

# Step 2: Use discovered columns to filter PPC data
custom_filter = {
    "impressions": {"type": "number", "condition": ">", "value": 1000},
    "acos": {"type": "number", "condition": "<", "value": 30}
}

ppc_data = requests.get(
    f"{base_url}/ppc/get-list",
    headers=headers,
    params={
        "account_title": "My Store US",
        "ppc_type": "sp",
        "entity_type": "campaigns",
        "per_page": 100,
        "currency": "USD",
        "custom_filter": json.dumps(custom_filter)
    }
).json()

for campaign in ppc_data["data"]:
    print(f"{campaign['campaign_name']}: {campaign['impressions']} impressions, {campaign['acos']}% ACoS")