To download files via script

We are writing a script to call an API. This API will returns a file url.
We want to download the file using the file url.
Can we achieve this?

You want to add the file URL to the Attachments field? I think this article explains it.