Skip to main content

GraphQL API

GraphQL lets a client choose related fields in one request. Maglane exposes workspace reads and a settings mutation through it. Use REST for resource operations such as imports, lifecycle changes, source management, invitations, and listener creation. The two APIs share authentication and workspace access.

Endpoint​

POST /api/graphql

GraphQL uses the same bearer token auth and workspace selection as REST. Send X-Workspace-ID, or omit it to use the account's default membership. Viewer or higher is required for queries; the settings mutation requires operator or higher.

Request envelope​

{
"query": "query { viewer { id email } }",
"variables": {}
}

Root fields​

Current schema exposes workspace-scoped data through:

  • Query.viewer
  • Mutation.updateUserSettings(input: UpdateUserSettingsInput!)

Viewer data​

viewer includes:

  • Identity: account id, email, and global instance role
  • Settings: workspace protocol/checker settings, judges, scraping source URLs, and per-member/workspace table-column preferences
  • Dashboard: counts and breakdowns
  • Proxy metrics: proxyCount, proxyLimit, proxyHistory, proxySnapshots
  • Paged resources: proxies(page: Int!), scrapeSources(page: Int!)
  • Scrape-source URL helper list: scrapeSourceUrls

Example dashboard query​

Start with a small query while establishing authentication:

query CurrentWorkspace {
viewer {
id
email
proxyCount
proxies(page: 1) {
totalCount
items { id ip port state healthKnown alive }
}
}
}

viewer.id is the account ID. Workspace-scoped fields use the membership selected by the header. healthKnown: false means the current settings have no applicable evidence, even when the compatibility alive field is false.

The following larger query selects dashboard data and one proxy page. Send {"proxyPage": 1} as its variables object:

query DashboardData($proxyPage: Int!) {
viewer {
dashboardView {
status
rebuilding
checkerSettingsPending
healthOutdated
collectedAt
healthCollectedAt
info {
totalChecks
checksThisMonth
totalScraped
reputationBreakdown { good neutral poor unknown }
countryBreakdown { country count }
}
recentProxyChecks(limit: 8) { id ip port alive latestCheck }
fastestAliveProxies(limit: 100) { id ip port responseTime country }
aliveCount
proxyCount
}
proxyCount
proxyLimit
proxies(page: $proxyPage) {
page
pageSize
totalCount
items {
id
ip
port
estimatedType
responseTime
country
anonymityLevel
alive
healthKnown
latestCheck
state
pauseReason
tags { id name color }
}
}
proxyHistory(limit: 168) { count recordedAt }
proxySnapshots(limit: 168) {
alive { count recordedAt }
scraped { count recordedAt }
}
scrapeSourceCount
}
}

Dashboard view​

viewer.dashboardView serves the dashboard from a snapshot shared by all backend instances. status says how current it is:

StatusMeaning
FRESHPublished less than 30 seconds ago, or during this request.
STALEOlder, up to ten minutes, or the last rebuild failed while some part is still valid.
PENDINGNo valid snapshot yet; a rebuild is pending or running.
FAILEDThe last rebuild failed and no part is valid.

A request that finds a snapshot older than 30 seconds, or one without health for the current checker settings, starts at most one rebuild and waits up to two seconds for it. rebuilding is true while a rebuild runs on any instance. Clients that see PENDING or rebuilding can ask again after a few seconds; the dashboard page does so for up to a minute, and for up to 30 minutes while healthOutdated is true.

  • Snapshot fields are null while the snapshot has no valid value for them, never zero. info itself is never null.
  • info.totalChecks and info.checksThisMonth are read live from the usage meter on every request, in every status. collectedAt does not describe them. Both count outbound check requests, retries included; they are Floats because lifetime totals exceed the 32-bit GraphQL Int.
  • aliveCount, recentProxyChecks, fastestAliveProxies and info.judgeValidProxies are the health fields. Results under new checker settings take time to build. Until then the health fields keep the previous result, computed under the earlier settings, and healthOutdated is true. healthCollectedAt says when that result was collected. checkerSettingsPending is true while the backend is still applying the change. The health fields are null only when no result was ever built.
  • recentProxyChecks accepts a limit up to 50 and fastestAliveProxies up to 100.
  • The field is resolved once per request: aliases share one result and one wait. proxySnapshots takes its latest alive point from the same snapshot.

Update settings mutation​

Mutation variables use an input object. For a column-only change, for example:

{"input":{"proxyListColumns":["ip_port","tags","country"]}}

This preserves workspace checker settings and changes only the authenticated member's columns in that workspace. A mutation that supplies checkerSettings replaces Default and all rules together. Read the current configuration before constructing that replacement.

mutation Update($input: UpdateUserSettingsInput!) {
updateUserSettings(input: $input) {
checkerSettings {
defaults { protocols transport timeout retries }
rules { tagId mode protocols transport timeout retries }
}
httpProtocol
httpsProtocol
socks4Protocol
socks5Protocol
timeout
retries
useHttpsForSocks
autoRemoveFailingProxies
autoRemoveFailureThreshold
failureAction
judges { url regex }
scrapingSources
proxyListColumns
scrapeSourceProxyColumns
scrapeSourceListColumns
}
}

Input fields are optional. Supported fields include the checker booleans, timeout, retries, autoRemoveFailureThreshold, failureAction, judges, and column-list arrays. Omitted fields retain their current values.

  • The legacy scalar timeout field accepts integers from 0 to 65535. New checkerSettings profiles require a timeout of 1 to 65535 ms.
  • retries and autoRemoveFailureThreshold accept integers from 0 to 255.
  • Values outside these ranges are rejected before settings are saved.
  • failureAction accepts "pause" or "delete", with "pause" as the default. Omitted or empty values preserve the stored choice. Unsupported values are rejected before any settings are saved. autoRemoveFailingProxies enables the selected action. See automatic failure action for deletion scope, rediscovery, and startup behavior.
  • Judge changes refresh the checker cache and are broadcast to other backend instances. Blocked judge websites are rejected, as in REST.
  • scrapingSources is a response field only. Manage sources through the REST scrape-source endpoints. The previously accepted, no-op scrapingSources mutation input has been removed; clients must omit it from mutation variables.

The mutation saves settings for the selected workspace, despite the legacy updateUserSettings name.

Proxy list items expose healthKnown. When false, alive: false means the current configuration has no applicable evidence, not a confirmed failure.

Tag checker settings​

UpdateUserSettingsInput.checkerSettings accepts the same behavior as REST, using lists for protocols and GraphQL IDs for tags:

{
"input": {
"checkerSettings": {
"defaults": {"protocols": ["socks5"], "transport": "tcp", "timeout": 7500, "retries": 2},
"rules": [
{"tagId": "42", "mode": "add", "protocols": ["http"], "timeout": 5000, "retries": 0}
]
}
}
}

Providing this field saves Default and rules atomically. Default requires a protocol-name list and shared transport, timeout, and retries. The rules list is highest priority first. Omitted or null rule fields inherit independently. Explicit fields apply to every enabled protocol. Remove rules contain only tag identity, mode, and protocol names. Timeouts accept 1-65535 ms and retries accept 0-255. Validation, including all reachable tag combinations, and workspace tag ownership checks are shared with REST. Omitting checkerSettings preserves rules.

viewer.settings.checkerSettings and the settings mutation response expose the same shared profile objects. See Default and tag settings for merging, inheritance, and health behavior.

Query guardrails​

GraphQL requests are validated before execution:

  • Max query bytes: GRAPHQL_MAX_QUERY_BYTES (default 16384)
  • Max depth: GRAPHQL_MAX_DEPTH (default 12)
  • Max field count: GRAPHQL_MAX_FIELDS (default 250)
  • Introspection disabled by default unless GRAPHQL_ALLOW_INTROSPECTION=true

Violations return HTTP 400 or 413 with {"error": ...}.

Error format​

GraphQL resolver errors follow the GraphQL response shape and can accompany HTTP 200. A response can also contain partial data. Inspect errors before using an HTTP success status as proof that every requested operation succeeded:

{
"errors": [
{"message": "unauthenticated"}
]
}

Authentication and guards can instead reject the request with an HTTP error before a resolver executes. Handle both forms. See error handling.