How can I extract all orders using Python?

I am trying to source all Orders using python and I’m having issues applying the parameter, status=any. Below is my code using paging but I’m willing to change my approach as long as I get ALL Orders records.

def get_orders():
count = requests.get(
rest_admin_api(“orders/count.json”),
headers=headers
).json().get(“count”)
print(f"getting all {count} orders")

orders = pd.DataFrame()
endpoint = “orders.json?status=any”

while len(orders) < count:
response = requests.get(
rest_admin_api(endpoint),
headers=headers
)

if response.ok:
page_link = response.headers.get(“Link”)

print(page_link)

page_info = re.match(r".page_info=(.)>", page_link)[1]

print(page_info)

page_df = pd.DataFrame(response.json().get(“orders”))

if len(orders :disappointed_face:
orders = pd.concat([orders, page_df])
else: orders = page_df

endpoint = f"orders.json?page_info={page_info}"
else: return Exception(response.reason)
orders = orders.reset_index(drop=True)
return orders

Have you got all orders?
If yes, Please share your solution. I also want to get all orders.