API Endpoint URL to exclude specific order tags

Solved

API Endpoint URL to exclude specific order tags

Ram_A
Explorer
60 3 29

Hi,

I'm trying to retrieve the orders that don't have an "exported" tag.

 

I tried these :
tag!=exported
tags!=exported
tag=-exported
exclude_tag=exported 
exclude_tag=-exported 
exclude_tags=exported 
exclude_tags=-exported 

This code printed out all orders, including the one with the "exported" tag:

 

  ## testing the endpoint URL excluding tags

import requests

# Set the Shopify API Key and Store URL
API_KEY = "****"
STORE_URL = "https://****.myshopify.com"

# Define the Shopify Orders endpoint and headers
ORDERS_ENDPOINT = f"{STORE_URL}/admin/api/2023-01/orders.json?limit=250&tag!=exported"
headers = {
    "Content-Type": "application/json",
    "X-Shopify-Access-Token": API_KEY
}

# Retrieve all the orders using Shopify's pagination feature
while ORDERS_ENDPOINT:
    response = requests.get(ORDERS_ENDPOINT, headers=headers)
    response_json = response.json()

    # Check if there are any more pages to retrieve
    ORDERS_ENDPOINT = response.links.get("next", {}).get("url")

    # Print the order numbers
    for order in response_json["orders"]:
        print(order["order_number"])

 



I would appreciate any help, thnx

Accepted Solution (1)

pranav8
Visitor
1 1 0

This is an accepted solution.

Reply 1 (1)

pranav8
Visitor
1 1 0

This is an accepted solution.

https://6c9e3a-2.myshopify.com/admin/api/2024-01/orders.json?tag_not=exported 
use the api like this... it worked for me... "tag_not"