Selected field names (tracked through chaining for precise autocomplete)
Included relations (tracked through chaining with proper cardinality)
Protected OptionalapiPer-call API key override, set via apiKey.
ProtectedfiltersProtectedqueryProtectedselectedProtectedskipWhen true, this call bypasses the response cache. Set via skipCache.
ProtectedsubqueriesProtected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyQUERIES_Queries that return data directly without wrapping in a 'data' object. These queries follow a different GraphQL schema structure.
Use a specific API key for this call instead of the client's default key.
The Politics & War API key to authenticate this query with.
This query builder instance for method chaining.
ProtectedbuildBuild the final GraphQL query string with comprehensive validation.
Constructs a complete GraphQL query including:
Validation includes:
Whether to include pagination info in response
Complete GraphQL query string ready for execution
Execute the API key details query and return a single object.
Important: Unlike nations/alliances queries, this returns a single object, not an array. There is no pagination support.
Results only include selected fields and included relations. All other fields are excluded from the response.
Single API key details object with selected fields and included relations
// Returns single object (NOT an array)
const apiKey = await query.execute();
// Type: { key: string, requests: number }
console.log(apiKey.key); // Direct access - no [0] needed
// With nested data
const apiKey = await pnwkit.queries.apiKeyDetails()
.select('key')
.include('nation', b => b.select('id', 'nation_name'))
.execute();
console.log(apiKey.nation.nation_name); // Direct nested access
Include related data in the query results
Supports unlimited recursive nesting with full type inference at every level. Each nested builder receives complete type safety for fields, relations, and query parameters.
New query instance with included relation
// Basic subquery - include nation data
.include('nation', builder => builder
.select('id', 'nation_name', 'score')
)
// Deeply nested query with unlimited depth
.include('nation', builder => builder
.select('id', 'nation_name')
.include('alliance', builder2 => builder2
.select('id', 'name', 'score')
.include('nations', builder3 => builder3
.select('id', 'nation_name')
)
)
)
// Important: Always select at least one scalar field at each level
// GraphQL requires this - you cannot query an object without selecting fields
ProtectedsanitizeSanitize and escape a string value for safe GraphQL usage.
Validates input type and length, checks for null bytes, and escapes special characters including backslashes, quotes, newlines, carriage returns, tabs, form feeds, and backspaces.
The string to sanitize
Sanitized string with all special characters properly escaped
Select specific fields to retrieve from API key details
Field names to select
New query instance with selected fields
ProtectedserializeSerialize an object to GraphQL format (enum values without quotes).
Validates object structure and prevents prototype pollution by:
Plain object to serialize (not arrays)
GraphQL-formatted object string in format {key:value, ...}
Bypass the response cache for this call.
Only meaningful when caching is enabled on the client (cache.enabled).
The result is fetched fresh from the API and is neither read from nor
written to the cache. No effect when caching is disabled.
This query builder instance for method chaining.
Query builder for fetching API key details from the Politics & War API.
Create new instances using the factory method:
pnwkit.queries.apiKeyDetails()Each call creates a fresh instance with no shared state.Important differences from other queries:
nation(the nation associated with the API key)Features:
Return type:
execute()→ Returns single API key details object (NOT an array)Example