How to retrieve custom field image files?
Without more context about what the API call you're making is, I can't say why it just returns a number.  Here's what happens when I call the API from my command line to get the results of the attachment with an ID of 1:

» cv api attachment.get id=1
{
    "is_error": 0,
    "version": 3,
    "count": 1,
    "id": 1,
    "values": {
        "1": {
            "id": "1",
            "name": "Project_Properties_dmaster_677.png",
            "mime_type": "image/png",
            "description": "",
            "upload_date": "2018-11-27 22:19:47",
            "entity_table": "civicrm_activity",
            "entity_id": "628",
            "icon": "fa-file-image-o",
            "created_id": "",
            "url": "http://dmaster.localhost/civicrm/file?reset=1&amp;id=1&amp;eid=628",
            "path": "/home/jon/local/civicrm-buildkit/build/dmaster/sites/default/files/civicrm/custom//Project_Properties_dmaster_677_ab277eebda5f50aeb9910018ab356f34.png"
        }
    }
}


It returns the URL property which I can output in an HTML file within an &lt;img&gt; tag to display the image on a web page.