Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

Descendants query from RT #601

Open
jamesamcl opened this issue May 25, 2022 · 0 comments
Open

Descendants query from RT #601

jamesamcl opened this issue May 25, 2022 · 0 comments

Comments

@jamesamcl
Copy link
Member

jamesamcl commented May 25, 2022

Copied from RT

I am using the link below to get the descendants of diabetes. At the end of
the link it shows that this page had total 78 id's and 4 pages and the
current page is only showing 20 elements (data for 20 id's)

},
"page" : {
"size" : 20,
"totalElements" : 78,
"totalPages" : 4,
"number" : 0
}
}

https://www.ebi.ac.uk/ols/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0000400/descendants
.

I used the following python script for getting all the pages and elements
at one go

import requests
des = {'page':0, 'size': 78}
data = requests.get('https://www.ebi.ac.uk/ols/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0000400/descendants',
params=des)
data.json()

The above script gave all the pages in one json file. But the issue is that
I have to check every time *totalElement *(as the database will keep
updating) before running the script, which is not ideal for the automation
process.

Is there any way the script can automatically detect the totalElements and
use that in the size of the step* des = {'page':0, 'size': 78}?*

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant