fascinating-indigo
fascinating-indigo3y ago

Can't get list of datasets from the API

I know it will sound as a meme... I wrote some code last week where i get a list of all dataset id from the API, it work great back then but today it stop. i found out that i was out of my budget so i had extra credit but it keep not working. def _get_datasets_ids(self, limit: int = 0, offset: int = 0, unnamed: bool = True, desc: bool = True) -> 'list[str]': """Returns a list of dataset IDs""" params = "token": self.API, "limit": limit, "offset": offset, "desc": desc, "unnamed": unnamed, } response = requests.get(f"{self.base_url}/datasets", params=params) if response.status_code != 200: # handle error raise Exception(f"Error fetching dataset IDs: {response.text}) dataset_ids = [item["id"] for item in response.json()["data"]["items"]] return dataset_ids
1 Reply
adverse-sapphire
adverse-sapphire3y ago
Hi @A. Morgan, could you please provide the error message you are getting? The code looks fine.

Did you find this page helpful?