Lookup API

You can use this endpoint to upload files that can be used by the match() function.

You can upload files in CSV or JSON format. Upload files as multipart form data. The file should be in a part named file.

Files can be uploaded to a repository or files can be uploaded as shared files that are available in all repositories. Uploading a file with the same name will replace the original file that was uploaded previously. Shared files are visible in all repositories and can be used by all users. Only root users can upload, delete and edit shared files. Shared files are referenced from functions like match(), by filename preprended with /shared/. For example /shared/myfile.csv

Example: Using curl to Upload a File to a Repository

Replace myfile.csvn with the path to your file (where $YOUR_LOGSCALE_URL is the URL for your LogScale instance.

shell
$ curl https://$YOUR_LOGSCALE_URL/api/v1/repositories/$REPOSITORY_NAME/files \
  -H "Authorization: Bearer $API_TOKEN" \
  -F "file=@myfile.csv"

Example (on-prem only): Using curl to Upload a Shared File Available in All Repositories

This example only applies to on-Premises (non-Cloud) users:

shell
$ curl https://$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared \
  -H "Authorization: Bearer $API_TOKEN" \
  -F "file=@myfile.csv"

See Example: Using curl to Delete a File from All Repositories to delete the file.

Example: Using curl to Delete a File from All Repositories

For on-Premises users, a shared file can be deleted using:

shell
$ curl -X DELETE https://$YOUR_LOGSCALE_URL/api/v1/uploadedfiles/shared/myfile.csv \
  -H "Authorization: Bearer $API_TOKEN"

For Cloud users, a file can be deleted from all repositories using:

shell
$ curl -X DELETE https://YOUR_LOGSCALE_URL/api/v1/repositories/REPOSITORY_NAME/files/myfile.csv

Example Contents for a CSV File

Whitespace gets included in the keys and values. To include the separator "," in a value, quote using the " character.

csv
userid,name
1,chr
2,krab
"4","p,m"
7,mgr

Example: contents for a file in JSON format using an object as root of the file.

In this variant, the key field does not have a name.

json
{
  "1": { "name": "chr" },
  "2": { "name": "krab" },
  "4": { "name": "pmm" },
  "7": { "name": "mgr" }
}

Example: contents for a file in JSON format using an array as root of the file.

In this variant, you select which field is the key using the field parameter in match().

json
[
  { "userid": "1", "name": "chr" },
  { "userid": "2", "name": "krab" },
  { "userid": "4", "name": "pmm" },
  { "userid": "7", "name": "mgr" }
]