Skip to main content

pnwkit-py

Separate install to prevent name squatting and allow pnwkit as a valid install name.

Logo

pnwkit-py

Politics & War V3 API Library
Explore the docs

JavaScript/TypeScript Version - Report Bug - Request Feature

PnWKit is here to make interacting with the V3 Politics and War API easy. All you have to do is import the library, add your key, and make a query.

Getting Started

To get started using pnwkit-py you must first have Python and PIP installed.

Installing

Python 3.9 or higher is required.

Install the library using PIP.

# Linux/MacOS
python3 -m pip install -U pnwkit

# Windows
py -3 -m pip install -U pnwkit

Usage

To use pnwkit-py just import the library and add your key, then you can make synchronous or asynchronous queries.

import pnwkit
pnwkit.set_key("xxxxx");

nations = pnwkit.nation_query({"id": 100541, "first": 1}, "nation_name")

print(f"Nation name: {nations[0].nation_name}")

If you want to paginate your query for more results, just enable pagination after your query.

nations = pnwkit.nation_query({"id": 100541, "first": 1}, "nation_name", paginator=True)

print(f"Nation name: {nations.data[0].nation_name}, current page: {nations.paginator_info.currentPage}")

The queries are written in normal GraphQL, so you can get all the cities in a nation like this

nations = pnwkit.nation_query({"id": 100541, "first": 1},
  """
  nation_name
  cities {
    name
  }
  """)

print(f"First city of ${nations[0].nation_name}: ${nations[0].cities[0].name}");

If you want to have multiple copies of pnwkit-py running at the same time, you can use the Kit class export.

import Kit from pnwkit;

other_kit = Kit(api_key="xxxx");

// queries...

Unlike the JavaScript/TypeScript library, the Python library has a few additional features.

  • To use the asynchronous client (aiohttp as opposed to requests) append async_ to your queries on the pnwkit module, or import async_pnwkit from pnwkit and run queries as normal, with the addition of an await statement.
  • If the params argument is falsy in a query (i.e. None or an empty dict) then any additional kwargs on the query will be interpreted as params.
  • Additional arguments on a query will be concatenated with the first to form the query.

You can also do the following queries in pnwkit-py:

  • nation_query
  • alliance_query
  • trade_prices_query
  • trade_query
  • war_query
  • treasure_query
  • color_query

You can look at the arguments and possible data to collect here at the docs.

Release files for pnwkit 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pnwkit 2.0.0
File Size Uploaded
pnwkit-2.0.0.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pnwkit 2.0.0
File Interpreter ABI Platform
pnwkit-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.3 kB

Release files / pnwkit-2.0.0.tar.gz

Download URL pnwkit-2.0.0.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6f78804a70f91ac785a41aceaaa8c0082ca7c4b30095156cca6357d922c9932b
BLAKE2b-256 checksum
How to use checksums
34f8018561230eefdecab155d9e50b9a064f16b1daae9779cfbe1de51611aa26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.7

Release files / pnwkit-2.0.0-py3-none-any.whl

Download URL pnwkit-2.0.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
189bdf88ac7f9bed6865b4be6f100307beae2b309d9b1ef2635bb2177796763a
BLAKE2b-256 checksum
How to use checksums
026bc289d3d006e5b3b2cda989535368e1fc99198d35d570c2ceeb628b5b4dd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.7

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page