Summary

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

API Stability Long-Term

Syntax

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

For the input, you'll have to give the name of the repository, and the file. You may also give text on which to filter contents, the number of lines to get and a starting line.

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

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.

Input Parameters

For the input, you would provide the name of the repository, and the name of the file to get. You may also give text on which to filter contents, the number of lines to get and an offset.

Table: v

Parameter Type Required Default Description
This table contains all input parameters for this query.
fileName string yes   The name of the file to get.
filterString string     A filter related to the file's content.
limit integer     The number of lines to select in the CSV file.
name string yes   The name of the search domain.
offset integer     An offset, a starting point for the number of lines to get.

Returned Values

For the results, you can get 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 Datatype

ParameterTypeRequiredDefaultStabilityDescription
Some input parameters may be required, as indicated in the Required column. For return values, this indicates that you are assured a value if the field is requested for 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.