pnwkit 3.0 - v4.3.0
    Preparing search index...

    Class default

    Main PnWKit client for interacting with the Politics & War API.

    Provides a type-safe, fluent API for querying Politics & War GraphQL endpoints with built-in retry logic, rate limiting, and optional caching.

    // Simple usage without caching
    const pnwkit = new PnWKit("your-api-key");

    // With LRU caching enabled (recommended for production)
    const pnwkit = new PnWKit("your-api-key", {
    cache: {
    enabled: true,
    ttl: 60000, // Cache for 1 minute
    maxSize: 100 // Store up to 100 queries
    }
    });

    // Query nations with filters
    const nations = await pnwkit.queries.nations()
    .select('id', 'nation_name', 'score')
    .where({ min_score: 1000, first: 10 })
    .execute();

    // Query alliances with nested relations
    const alliances = await pnwkit.queries.alliances()
    .select('id', 'name')
    .include('nations', builder => builder.select('id', 'nation_name'))
    .where({ first: 5 })
    .execute();

    // Manage cache
    pnwkit.clearCache(); // Clear all cached queries
    const stats = pnwkit.getCacheStats(); // Check cache utilization

    Hierarchy

    • default
      • default
    Index
    • Create a new PnWKit instance.

      Parameters

      • apiKey: string

        Your Politics & War API key

      • Optionaloptions: PnWKitOptions

        Optional configuration including cache settings

      Returns default

      // Without caching
      const pnwkit = new PnWKit("your-api-key");

      // With caching
      const pnwkit = new PnWKit("your-api-key", {
      cache: { enabled: true, ttl: 60000, maxSize: 100 }
      });
    apiKey: string

    Politics & War API key for authentication

    cacheOptions?: CacheOptions

    Cache configuration (if enabled)

    dataDumps: DataDumps

    Access to the Politics & War daily data dumps

    mutations: Mutations

    Mutation builders for all Politics & War GraphQL mutations

    queries: Queries

    Query builders for all Politics & War GraphQL queries

    subscriptions: Subscriptions
    utilities: Utilities

    Utility functions for calculations and data transformations

    • Clear all cached query responses.

      Useful for forcing fresh data retrieval or managing memory usage. Safe to call even if caching is disabled.

      Returns void

    • Get cache statistics including current size and maximum capacity.

      Returns { max: number; size: number } | undefined

      Object with size (current entries) and max (capacity limit), or undefined if caching is disabled