Querying data with API

Hi, I'm practicing querying Metabase and I can't seem to get an API query to work. (I am pretty new to APIs in general.) I would love to see a start-to-finish example of a functioning API that will download a large data file!

Basically my problem is I can't seem to structure a working query using the API. I can retrieve metadata for the database, tables, fields, and cards/questions. I thought that in my browser if I followed up a card ID with /query/json like so:

my-mb-site.my-company.com/api/card/12345/query/json

it should return a large JSON data object, but it doesn't. It says "API endpoint does not exist."

I tried using the code below. I know I'm authenticating, because I'm getting email alerts that I've logged in from a "new location", but it's telling me the same message, "API endpoint does not exist."

def get_metabase_data(query_ids, username, password, url):
session = requests.Session()
login_data = {"username": username, "password": password}
session.post(f"https://{url}/api/session", json=login_data)
dfs =
if isinstance(query_ids, int):
query_url = f"https://{url}/api/card/{query_ids}/query/json"
response = session.get(query_url)
print(response.text)
if response.status_code == 200:
df = pd.DataFrame(response.json())
return df
elif isinstance(query_ids, list):
for query_id in query_ids:
query_url = f"https://{url}/api/card/{query_id}/query/json"
response = session.get(query_url)
print(response.text)
if response.status_code == 200:
df = pd.DataFrame(response.json())
dfs.append(df)
final_df = pd.concat(dfs, axis=0)
return final_df
else:
raise TypeError("The query_ids argument must be an integer or a list of integers")

Code copied from this forum question: "API endpoint does not exist." - Get Help - Metabase Discussion Probably a bad sign I'm getting the same result they did...