The Python module legacystamps provides easy retrieval, both standalone and scripted, of FITS and JPEG cutouts from the DESI Legacy Imaging Surveys through URLs provided by the Legacy Survey viewer.
Please see citation information here: https://github.com/tikk3r/legacystamps#acknowledgements