add download API, closes #529