Skip to content
Last updated

File Download in Xpansiv Data

To download a file, you must first find the file ID using the search API.


Search files within a given group.

HTTP Request

GET https://api.data.xpansiv.com/file/search?size=<size>&from=<from>&query=<value>

Example

curl "https://api.data.xpansiv.com/file/search?query=groupName%3D<groupName>"

Response

{
  "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

ParameterDescription
sizeOptional. Max size of returned hits list. Default is 100. Max is 1000.
fromOptional. Index of the first hit for paging. Default is 0.
queryValue 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/<fileId>/download

Example

curl "https://api.data.xpansiv.com/file/<fileId>/download"

URL Parameters

ParameterDescription
fileIdThe 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/<fileId>

Example

curl "https://api.data.xpansiv.com/file/<fileId>"

Use the presigned URL from the Location header to download the file:

curl -X GET "LocationURL"

Response

{
    "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

curl "https://api.data.xpansiv.com/file/search?size=10&from=0&query=value1"

Response

{
  "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=<size>&from=<from>&query=<value>

Example

curl "https://api.data.xpansiv.com/file/search/regexp?size=10&from=0&query=value1" -H "Authorization: Bearer yourNgToken"

Response

{
  "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
    }
  ]
}