I see. Well, in that case you can of course do it through API, but maybe Logstash
service is better for exporting and transforming the data?
I'm not trying to steer you away from your idea, what I'm saying is that ELS has it's tools which can do it more efficiently and easily.
That being said, if you'll still want to go with your approach try using search query.
curl -k -u admin:password -XGET "http://localhost:9200/some-index-name/_search?pretty"