Skip to main content

A Python wrapper for the NationStates API

Project description

NaStyAPI - A NationStates wrapper

PyPi status Documentation Status
A Python wrapper for the NationStates api.
Works with a rate limit so as not to exceed NationState's API's rate limit.
GitHub Link

Table of Contents:

Installation

The package is available on PyPi! simply write:
pip install NaStyAPI

Documentation

Link to full documentation (extremely outdated)

General Use

The NationStates API is divided into parts, and so is the wrapper. The parts are:

  • Nation
  • Region
  • Telegrams
  • TradingCards
  • World
  • WorldAssembly

To use a part, simply write:

from NaStyAPI import Part

Warning

I take no responsibility for mistakes and errors that are caused by the use of this software. This is still in development and should not be used to handle sensitive or important information.

Examples

Recommendation

NationStates requires ("must") api users to specify a User-Agent. The default User-Agent is "A NaStyAPI User. Contact Roddy.Rappaport@gmail.com for issues.", and NationStates requires that the user agent will be "something informative, such as the URL of your site or your e-mail address. It can be whatever you want, so long as it allows us to contact you if something goes wrong with your script."

from NaStyAPI import APICall
APICall.set_user_agent("Your Email")

Log in to your nation

from NaStyAPI import Nation
your_nation = Nation.Nation("NATION_NAME")
your_nation.log_password("YOUR_PASSWORD")

Get a shard on a nation

from NaStyAPI import Nation
your_nation = Nation.Nation("nation_name")
your_nation.log_password("YOUR_PASSWORD")  # If shard is private, else not needed
your_nation.shard

Get multiple shards

from NaStyAPI import Nation
your_nation = Nation.Nation("nation_name")
your_nation.get_shards(["shards"])

Write a dispatch using the api

from NaStyAPI import Nation
your_nation = Nation.Nation("nation_name")
your_nation.log_password("password")
new_dispatch = your_nation.add_dispatch("title", "text", "category", "sub_category")

To-do

This is a list of the features I am currently working on that should be ready quite soon.

  • Finding bugs.
  • Handling edge cases.
  • Adding descriptions and updating docs.

How to contribute

Thank you for looking at this! If you want to contribute, feel free to update the docs in the /docs/ folder. I am still adding features, so I didn't have the time to do it myself.

Show Support

My in-game nation is "Khiralia", if you want to show support feel free to telegram a nice message :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NaStyAPI-0.3.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NaStyAPI-0.3.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file NaStyAPI-0.3.0.tar.gz.

File metadata

  • Download URL: NaStyAPI-0.3.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for NaStyAPI-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9a4e4c7781acad88363e0ad0b33e9d8ebbb2c94f8f00a1ea1d1c08b56240678b
MD5 ef47f4aad23b624d93ae5f0c61c5da93
BLAKE2b-256 1f223855cd8463918aefd4a9c883049fdae4cee1f73837b0e20453056e5742f1

See more details on using hashes here.

File details

Details for the file NaStyAPI-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: NaStyAPI-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for NaStyAPI-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6de29e39cf268b1520465f00ec1cc9051e4f7b78aa1408e57adc809ef80be25
MD5 b6d6e195ca2947b8e0e38432d5550c7e
BLAKE2b-256 6b0773ce70061a624a8ffd47cc9d1cfb02985317ee3d3061c77d8aa0ab5d5ea5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page