Page 1 of 1

Nationstates API for python

PostPosted: Thu Oct 08, 2015 1:40 pm
by The United Island Tribes
Image Image

You may have seen my posts on other threads, but I have been writing an API wrapper for python. This is official thread for the project.

You can find all info/installation/documentation here - GitHub Repository
I will answer any questions dealing with module in this thread.

General FAQ:

Are all shards supported? - Yes

Is this Open Source? - Yes. This package is licences under MIT. This basically means you can use it for any reason (Please defer to the License for the actually agreement)

Is this project actively developed? - Yes.

Can I send Telegrams? - Yes (2.0+ Only)

Can I use private shards? - Yes.

Does it have built-in ratelimiting? - Yes.

Does it support the Verification api? - Yes

Does it support private commands? - Yes

Where can I get help - Alongside the Github Issue tracker, the author sits in discord server for nationstates coders - https://discord.gg/yYupzZQz



Can You give me actual examples of the above? - See the Github Repo for documentation. Feel free to post a issue if you can't find docs on what you want to do.

Bugged Releases

PostPosted: Tue Jan 05, 2016 1:38 pm
by The United Island Tribes
I am here to urge any users of the library to upgrade to 1.1.29.54 or newer. The last few releases contain a bug that can harm the nationstates site.

The Bug - Due to erroneous default behavior, unless you explicitly set auto_load to False while using nationstates.Api class, you will request the Api Twice with identical requests.
The Following Releases are affected by the bug.

1.1.28.41
1.1.28.46
1.1.28.47
1.1.28.48
1.1.29.52
1.1.29.53 (Partially, only for Authentication requests)

Please Upgrade to 1.1.29.54 if you are using these releases. All of these releases are compatible so it should be rather headache free.

use this command to upgrade
Code: Select all
pip install nationstates --upgrade



You can ban/contact the corresponding User-Agents (per https://www.nationstates.net/pages/api.html#terms)

python-nationstates/1.1.28.46
python-nationstates/1.1.28.47
python-nationstates/1.1.28.48
python-nationstates/1.1.29.52
python-nationstates/1.1.29.53

(These are Default User-Agents, custom ones may not include it)

Version 2.0 Annoucement

PostPosted: Thu May 31, 2018 6:37 pm
by The United Island Tribes
Hello all I am here to announce that I am going to start development on this again and release a 2.0.

I do want to warn any potential people using the the current library of the backwards incompatible changes though, as I consider it not good for anything besides personal scripts. Unfortunately for almost 2 years I've been too busy to give any attention to it. Looking at it now I don't think it is viable to continue with that codebase.

Going forward I am going to release 2 things:

1. An new extremely light weight, currently called nsapiwrapper. It's job is to generate the urls, handle the response from the server, and the ratelimit system. see https://github.com/DolphDev/nsapiwrapper if you want to see it be developed. I'm am still writing this but it's actually pretty near completion due to how simple it is and I am reusing much of the code from the current codebase.

2. The current nationstates library will be rewritten, and it will wrap around the nsapiwrapper and aims to become a very high level way to use the api. To give an idea how high level I am aiming for this to be, here is example usage of it (nothing is final though, this is just some of my goals). (Also to note: this will be the one installed if you do pip install nationstates)

(Note for moderators, I am also python_nationstates_api_wrapper for purposes of API keys or other matters.

Code: Select all
import nationstates

api = nationstates.Nationstates("My Awesome Script")
# Get the flag of the Nation's region
flag = api.Nation("The United Island Tribes").region.flag
# Shard request
shard_request = api.Nation.request(shards=["animal", "animaltrait"])

PostPosted: Tue Aug 14, 2018 10:34 am
by Frazikstan
Am returning to nationstates after a few years away, interested in this, as I can use it to host my own simplified REST endpoints and build a simple mobile [android] client against. That's the plan anyway, lol. Need time is all.

Alpha Available

PostPosted: Sun Oct 21, 2018 2:48 pm
by The United Island Tribes
Hello all, after dragging my feet on this for months an alpha of 2.0.0.0 is finally available

If you wish to try it out, you can do so at https://pypi.org/project/nationstates/2.0.0.0a0/

Issues/help can be asked on the github page.

Note: This is an alpha release, not intended for production use

First Official Release of 2.0+

PostPosted: Wed Jan 23, 2019 1:44 pm
by The United Island Tribes
Hello all, this post is to note 2.0.0.x releases have begun.

See https://pypi.org/project/nationstates/2.0.0.1/ for installation

Issues/help can be asked on the github page, see first post on this thread for links.

PostPosted: Wed Jun 05, 2019 2:12 pm
by The Pharcyde
First of all, thank you for your effort in creating this. It must've taken a ton of time.

I have a novice question. Is this considered single request or five requests?

import nationstates
from nationstates import Shard
from pprint import pprint

api = nationstates.Nationstates("Example for Nationstates API for python")

resp = api.world().get_shards(Shard("happenings", view="region.lazarus", filter='member', limit="5"))
pprint(resp.happenings)

PostPosted: Thu Sep 12, 2019 7:47 am
by The United Island Tribes
The Pharcyde wrote:First of all, thank you for your effort in creating this. It must've taken a ton of time.

I have a novice question. Is this considered single request or five requests?

import nationstates
from nationstates import Shard
from pprint import pprint

api = nationstates.Nationstates("Example for Nationstates API for python")

resp = api.world().get_shards(Shard("happenings", view="region.lazarus", filter='member', limit="5"))
pprint(resp.happenings)


I know this is way late, but this would be considered one request.

PostPosted: Fri Mar 06, 2020 9:07 am
by Nordlandenn
So I was looking into this package, and I am not sure what I am doing wrong but the package won't install for me, citing that I need VS C++ version 14.0,.. when I got that, it will not install because of
this error:

*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************

Is there any workaround? I am running Windows 10 x64 btw.

PostPosted: Mon Mar 09, 2020 10:06 am
by Merni
Nordlandenn wrote:So I was looking into this package, and I am not sure what I am doing wrong but the package won't install for me, citing that I need VS C++ version 14.0,.. when I got that, it will not install because of
this error:
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
Is there any workaround? I am running Windows 10 x64 btw.

Seeing as the last update was about a year ago, and the author has CTEd, it looks like this wrapper is no longer maintained. Try searching online on how to install libxml2. If that fails, you could try to use the requests or (builtin) urllib modules in Python to query the API directly and unpack the XML yourself using the builtin xml module. You'd need to take care of ratelimits yourself though.
Or, if you know another languages, there are other wrappers available. See https://www.nationstates.net/pages/api.html.

Back From my yearly boneyard

PostPosted: Fri Dec 04, 2020 10:16 pm
by The United Island Tribes
I'll try to get out 3.0.0.0 sometime in the next few months, stay tuned. This one will support cards and other things in the api

~~UPDATE~~

https://pypi.org/project/nationstates/3.0.0.0a0/ - Alpha has been released. I will be writing tests and documenting before marking it for full release

3.0.0.x series released

PostPosted: Fri Dec 11, 2020 10:37 pm
by The United Island Tribes
Hello,

the 3.x series for this module which added support for cards apis, new commands, and a litany of bug fixes is now available on pypi

https://pypi.org/project/nationstates/3.0.0.2/

pynationstates-async annoucement

PostPosted: Sat Dec 26, 2020 9:46 am
by The United Island Tribes
Hello all, people have requested this for years but I've decided to create an async version of pynationstates. it will be similar to pynationstates in it's aim to provide a simple easy to use full interface to the nationstates api (but for async). I'd only recommend it's usage over the original pynationstates where you need the async (such as a discord bot) - as the flow isn't as easy to understand especially for beginners. I'll create a new thread once the project is out of pre-alpha

PostPosted: Thu Apr 04, 2024 8:45 pm
by Reiserland
Seems like this project isn't being maintained anymore? The latest commit is 2 years ago.

PostPosted: Thu Apr 04, 2024 8:48 pm
by Daphomir
Dang this thread is old.

PostPosted: Fri Apr 05, 2024 1:27 pm
by Kractero
Reiserland wrote:Seems like this project isn't being maintained anymore? The latest commit is 2 years ago.

Things don't need to be updated if everything is working fine. There's no need to make useless commits just for the sake of committing.

PostPosted: Thu Apr 18, 2024 6:59 pm
by Reiserland
Kractero wrote:
Reiserland wrote:Seems like this project isn't being maintained anymore? The latest commit is 2 years ago.

Things don't need to be updated if everything is working fine. There's no need to make useless commits just for the sake of committing.

Sure, but the maintainer had just begun working on (the unreleased) 3.1.5 before seemingly abandoning it. Anyway, I never asked for it to be updated. I'm simply wondering about the status of the project, since it's featured in the official API docs.