Recently we were asked on GitHub whether there was a way to get all animal occurrences that are not a bird. This seems like an easy enough request, but unfortunately, there is currently no way to exclude groups from a download search and get everything but a certain group.

A user can get all birds, but they can’t get no birds!

I thought this was an interesting question and probably useful for other people wanting smaller downloads, since there are currenly around half a billion occurrence records for birds. I decided to get all the class keys that were not Aves (212) and make a no birds animal search query.

search query for all animals that are not a bird

This query above is all the taxon keys for classes that are not birds. You could also add taxon_key=6 to the end of this and get all plants and animals that are not a bird.

This brute-force approach of getting everything that is not of interest only works if your end query has less than 200 taxon keys. Fortunately for the case of animals, there are only 100 non-bird classes.

I generated this query using this R code.

library(roperators) # for %+% string operator

# api call to get all class keys for animals
base_url <- ""
params <- "rank=CLASS&highertaxon_key=1&status=ACCEPTED&status=DOUBTFUL&advanced=1&limit=200" 

url <- base_url %+% params

query <- httr::GET(url) %>% 
httr::content() %>% 
pluck("results") %>%
map(~ .x$classKey) %>%
map_chr(~ "taxon_key=" %+% .x) %>%
paste(collapse="&") %>%
str_replace_all("taxon_key=212&","") # remove birds 

# paste this result into a browser
"" %+% query