Is it possible to get all files, who don't have parents using google drive rest api query?
4 Answers
There's no query to find "orphaned" files. If you're looking for files that the user owns, you'd need to do files.list() with a query of 'me' in owners
and fields value of files(id,parents),nextPageToken
then locally filter down to files with no parents.

- 13,415
- 3
- 28
- 59
-
Guy Smith's answer below is a better option now. – Ryan Dec 29 '17 at 04:13
-
When I do `me in owners` I get a bunch of extra files, I think it is giving me all files in the entire account. Is it possible to request just root folders and those that don't have parents? – casolorz Nov 26 '20 at 18:00
This is now possible as explained in the documentation. To return all orphaned files you own use the following search query: is:unorganized owner:me
.
You can leave off the second part if you want all files owned by anyone, or replace the me
with any specific users email address to get their orphaned files.
NOTE: This is using the Web UI and not the API. This thread shows options available through the API.

- 392
- 5
- 13

- 43
- 3
Internally, Google uses an unparented = true
search phrase, but this does not appear to be available in the V2 or V3 REST APIs.

- 4,594
- 1
- 32
- 35
If by "don't have parents" you mean "aren't in a folder", then such files have 'root' as a default parent so you can search on that.

- 21,499
- 14
- 64
- 115
-
1You can search for root ```'root' in parents```, but it doesn't help, since orphaned files do NOT have root as a parent. – codingjoe May 30 '16 at 14:05
-
yes I agree. I was making an assumption about what the OP mean by "no parent". Jay's answer is the safest option, whereas mine was assuming that by "no parents", the OP means "files not moved to a subfolder" – pinoyyid May 30 '16 at 14:41