Skip to content

roddyrap/NaStyAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 :)