# File Download in Xpansiv Data To download a file, you must first find the file ID using the search API. ## 1. File Search Search files within a given group. ### HTTP Request `GET https://api.data.xpansiv.com/file/search?size=&from=&query=` ### Example ```shell curl "https://api.data.xpansiv.com/file/search?query=groupName%3D" ``` ### Response ```json { "from": 0, "totalSize": 4, "files": [ { "fileName": "file name", "fileType": "file type [SOURCE|NCSV|DOWNLOADER|DATA_PREP|GDP]", "groupName": "group name", "fid": "file id", "fields": { "text": "some text" }, "arrivalTime": "2018-01-01T12:00:00", "owner": "file owner", "size": 100 } ] } ``` ### URL Parameters | Parameter | Description | | --- | --- | | size | Optional. Max size of returned hits list. Default is 100. Max is 1000. | | from | Optional. Index of the first hit for paging. Default is 0. | | query | Value of the metadata field to look for. Must be URL encoded. | ## 2. File Content Download the contents of a given file ID. ### HTTP Request `GET https://api.data.xpansiv.com/file//download` ### Example ```shell curl "https://api.data.xpansiv.com/file//download" ``` ### URL Parameters | Parameter | Description | | --- | --- | | fileId | The ID of the file to download | ### HTTP Response The response is the file's content. ## 3. File Metadata Retrieve metadata of a specific file. The response headers include a presigned URL valid for one hour to download the file. ### HTTP Request `GET https://api.data.xpansiv.com/file/` ### Example ```shell curl "https://api.data.xpansiv.com/file/" ``` Use the presigned URL from the Location header to download the file: ```shell curl -X GET "LocationURL" ``` ### Response ```json { "fileName": "file name", "fileType": "file type [SOURCE|NCSV]", "groupName": "group name", "fid": "file id", "fields": { "fieldName": "field value" }, "arrivalTime": "2018-01-01T12:00:00", "owner": "file owner", "size": 0 } ``` ### Response Body - fileName: File name - fileType: File type [SOURCE, NCSV] - groupName: Group name - fid: File ID - fields: Metadata map - arrivalTime: Upload date - owner: User who uploaded the file - size: Size in bytes ## 4. File Search by Metadata Search files with metadata field1=value1 and return first 10 hits. ### Example ```shell curl "https://api.data.xpansiv.com/file/search?size=10&from=0&query=value1" ``` ### Response ```json { "from": 0, "totalSize": 4, "files": [ { "fileName": "file name", "fileType": "file type [SOURCE|NCSV|DOWNLOADER|DATA_PREP|GDP]", "groupName": "group name", "fid": "file id", "fields": { "text": "some text" }, "arrivalTime": "2018-01-01T12:00:00", "owner": "file owner", "size": 100 } ] } ``` ## 5. File Search by Regexp Search files using a regular expression. ### HTTP Request `GET https://api.data.xpansiv.com/file/search/regexp?size=&from=&query=` ### Example ```shell curl "https://api.data.xpansiv.com/file/search/regexp?size=10&from=0&query=value1" -H "Authorization: Bearer yourNgToken" ``` ### Response ```json { "from": 0, "totalSize": 4, "files": [ { "fileName": "file name", "fileType": "file type [SOURCE|NCSV|DOWNLOADER|DATA_PREP|GDP]", "groupName": "group name", "fid": "file id", "fields": { "text": "some text" }, "arrivalTime": "2018-01-01T12:00:00", "owner": "file owner", "size": 100 } ] } ```