ids <- names(your_list_object)
However, note that the ids will be saved as characters. So, if you want them numerically, you may have to use ids <- as.numeric(names(your_list_object))
.
Also, R generally provides many easy ways to extract 'names' attributes from objects. For example look at ?names, ?rownames, ?colnames, ?dimnames etc.