Skip to content

Instantly share code, notes, and snippets.

@kozo2
Created March 27, 2026 06:13
Show Gist options
  • Select an option

  • Save kozo2/0b7fa8d73e4839980a90ed3ab2115cb0 to your computer and use it in GitHub Desktop.

Select an option

Save kozo2/0b7fa8d73e4839980a90ed3ab2115cb0 to your computer and use it in GitHub Desktop.
MetaboLights assay index and maf file names
import requests
url = "https://www.ebi.ac.uk/metabolights/ws/studies"
response = requests.get(url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
studies = response.json()
mtbls_ids = data['content']
for study_id in mtbls_ids:
url = f"https://www.ebi.ac.uk/metabolights/ws/studies/public/study/{study_id}"
response = requests.get(url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
data = response.json()
for assay in data['content']['assays']:
print(study_id, assay['assayNumber'], assay['fileName'], assay['metaboliteAssignment']['metaboliteAssignmentFileName'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment