The allpages
API module allows you to do just that. Its limit (when you set aplimit=max
) is 500, so to query all 4.5M articles, you would need about 9000 requests.
But a dump is a better choice, because there are many different dumps, including all-titles-in-ns0
which, as its name suggests, contains exactly what you want (59 MB of gzipped text).