getFileContent()

API Stability Long-Term

The getFileContent() GraphQL query is used to get the contents of a CSV file.

For creating a new file, use the newFile() mutation field. To make changes to a file, you'd use the updateFile() mutation. Related to all of this, you might want to look at the Lookup Files page in the main documentation.

Syntax

graphql
getFileContent(
     name: string!,
     fileName: string!,
     filterString: string,
     offset: integer,
     limit: integer
   ): UploadedFileSnapshot!

For the input, there are no special datatypes. For the name, you'd enter the name (e.g., Our File) associated with the external file connection. This is possibly different from fileName, which is the actual CSV file name (e.g., our-file.csv). The filterString is for specifying a filter related to the content, but that's optional. The offset and limit parameters may be used to select the lines in the CSV file.

For the results, you can request the file path, the number of lines in the file, and any headers it contains. The Returned Datatype section has a table with more details.

Example

Below is an example with fictitious data:

Raw
graphql
query {
  getFileContent(
    fileName: "test.csv", 
    name: "humio", 
    filterString: "Barbara"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query { ^
  getFileContent( ^
    fileName: \"test.csv\",  ^
    name: \"humio\",  ^
    filterString: \"Barbara\" ^
  ) ^
  { nameAndPath{name, path},  ^
    totalLinesCount, ^
    headers, lines ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "query {
  getFileContent(
    fileName: \"test.csv\", 
    name: \"humio\", 
    filterString: \"Barbara\"
  )
  { nameAndPath{name, path}, 
    totalLinesCount,
    headers, lines
  }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "getFileContent": {
      "nameAndPath": {
        "name": "test.csv",
        "path": null
      },
      "totalLinesCount": 1,
      "headers": [
        "id",
        "first",
        "last"
      ],
      "lines": [
        [
          "6",
          "Barbara",
          "Mills"
        ]
      ]
    }
  }
}

This example is gets the file from the repository, and returns lines containing the search text given for filterString. It also returns the name and path of the file, and the number of rows found — which is only one here. And it returns the data found matching the search text.

Returned Datatype

This datatype can return the file path, the number of lines the CSV file contains, any headers and other such information. The table below describes what information would be available:

Table: UploadedFileSnapshot

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For return datatypes, this indicates that you must specify which fields you want returned in the results.
Table last updated: Sep 11, 2025
filterStringstring  Long-TermAny string on which to filter the data.
headers[string]yes Long-TermThe headers for the uploaded snapshot file.
limitintegeryes Long-TermThe file upload limit.
lines[string]yes Long-TermThe contents of the file in the form of a list of lines, with each line being itself a list of column values. When the file is empty or nothing matches filterString, then [] is returned.
nameAndPathFileNameAndPathyes Long-TermThe name and path of the uploaded snapshot file. See FileNameAndPath.
offsetintegeryes Long-TermThis is the offset supplied to a file query. For a new or updated file, this is always 0.
resourcestringyes Short-TermThe resource identifier for the file.
totalLinesCountlongyes Long-TermThe total number of lines in the uploaded snapshot file.