GraphQL API

Ferro provides a GraphQL endpoint built with async-graphql. A Playground UI is available in the browser.

Endpoint

POST /api/graphql
GET  /api/graphql   (Playground UI)

Schema Overview

Queries

QueryArgumentsDescription
filespath: String, limit: IntList files at a path (default limit: 100, max: 1000)
filepath: String!Get metadata for a single file
shares--List all share links
me--Get current user info
health--Server health check
audit_loglimit: Int, offset: IntQuery audit log entries

Mutations

MutationArgumentsDescription
create_folderpath: String!Create a directory
delete_filepath: String!Delete a file or directory

Types

FileItem

FieldTypeDescription
pathStringFull path
nameStringFile name
sizeIntSize in bytes
is_collectionBooleanWhether it is a directory
mime_typeStringMIME type
modifiedStringLast modified timestamp
ownerStringOwner username

ShareItem

FieldTypeDescription
tokenStringShare token
pathStringShared file path
expires_atStringExpiration timestamp
password_protectedBooleanHas password protection
max_downloadsIntMaximum download count
download_countIntCurrent download count
created_byStringCreator username

UserItem

FieldTypeDescription
usernameStringUsername
roleStringUser role

HealthItem

FieldTypeDescription
statusStringHealth status
versionStringServer version

AuditItem

FieldTypeDescription
methodStringHTTP method
pathStringRequest path
userStringUser who performed the action
statusIntHTTP status code
timestampStringWhen the action occurred

Examples

List root files

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ files(path: \"/\") { name size is_collection modified } }"}'

Get a specific file

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ file(path: \"/documents/report.pdf\") { path name size mime_type modified } }"}'

Create a folder

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { create_folder(path: \"/new-folder\") { path name } }"}'

Delete a file

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { delete_file(path: \"/old-file.txt\") }"}'

Query audit log

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ audit_log(limit: 10) { method path user status timestamp } }"}'

Check health

curl -X POST http://localhost:8080/api/graphql \
  -H "Content-Type: application/json" \
  -d '{"query": "{ health { status version } }"}'

List shares

curl -X POST http://localhost:8080/api/graphql \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ shares { token path password_protected download_count } }"}'

Playground

Open http://localhost:8080/api/graphql in a browser to access the interactive GraphQL Playground with schema documentation and auto-completion.