NATION

PASSWORD

Nationstates API for python

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Nationstates API for python

Postby The United Island Tribes » Thu Oct 08, 2015 1:40 pm

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.
Last edited by The United Island Tribes on Mon Dec 14, 2020 9:51 pm, edited 6 times in total.

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Bugged Releases

Postby The United Island Tribes » Tue Jan 05, 2016 1:38 pm

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)
Last edited by The United Island Tribes on Tue Jan 05, 2016 1:57 pm, edited 3 times in total.

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Version 2.0 Annoucement

Postby The United Island Tribes » Thu May 31, 2018 6:37 pm

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"])
Last edited by The United Island Tribes on Sun Jun 03, 2018 8:14 pm, edited 1 time in total.

User avatar
Frazikstan
Civilian
 
Posts: 1
Founded: Aug 02, 2005
Ex-Nation

Postby Frazikstan » Tue Aug 14, 2018 10:34 am

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.

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Alpha Available

Postby The United Island Tribes » Sun Oct 21, 2018 2:48 pm

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

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

First Official Release of 2.0+

Postby The United Island Tribes » Wed Jan 23, 2019 1:44 pm

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.

User avatar
The Pharcyde
Attaché
 
Posts: 88
Founded: Feb 15, 2019
Ex-Nation

Postby The Pharcyde » Wed Jun 05, 2019 2:12 pm

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)
Last edited by The Pharcyde on Wed Jun 05, 2019 2:16 pm, edited 2 times in total.
Fire Republic of Pharcyde
Огненная Република Фарсайда
The Pharcyde (II Wiki · Map · Interpol)

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Postby The United Island Tribes » Thu Sep 12, 2019 7:47 am

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.

User avatar
Nordlandenn
Lobbyist
 
Posts: 13
Founded: May 29, 2017
Inoffensive Centrist Democracy

Postby Nordlandenn » Fri Mar 06, 2020 9:07 am

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.

User avatar
Merni
Ambassador
 
Posts: 1800
Founded: May 03, 2016
Democratic Socialists

Postby Merni » Mon Mar 09, 2020 10:06 am

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.
Last edited by Merni on Mon Mar 09, 2020 10:12 am, edited 3 times in total.
2024: the year of democracy. Vote!
The Labyrinth | Donate your free time, help make free ebooks | Admins: Please let us block WACC TGs!
RIP Residency 3.5.16-18.11.21, killed by simplistic calculation
Political Compass: Economic -9.5 (Left) / Social -3.85 (Liberal)
Wrote issue 1523, GA resolutions 532 and 659
meth
When the people are being beaten with a stick, they are not much happier if it is called 'the People’s Stick.' — Mikhail Bakunin (to Karl Marx)
You're supposed to be employing the arts of diplomacy, not the ruddy great thumping sledgehammers of diplomacy. — Ardchoille
The West won the world not by the superiority of its ideas or values or religion [...] but rather by its superiority in applying organised violence. — Samuel P. Huntington (even he said that!)

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

Back From my yearly boneyard

Postby The United Island Tribes » Fri Dec 04, 2020 10:16 pm

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
Last edited by The United Island Tribes on Tue Dec 08, 2020 9:00 pm, edited 2 times in total.

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

3.0.0.x series released

Postby The United Island Tribes » Fri Dec 11, 2020 10:37 pm

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/

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 48
Founded: Oct 17, 2014
Left-wing Utopia

pynationstates-async annoucement

Postby The United Island Tribes » Sat Dec 26, 2020 9:46 am

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

User avatar
Reiserland
Political Columnist
 
Posts: 2
Founded: Apr 20, 2023
Liberal Democratic Socialists

Postby Reiserland » Thu Apr 04, 2024 8:45 pm

Seems like this project isn't being maintained anymore? The latest commit is 2 years ago.

User avatar
Daphomir
Chargé d'Affaires
 
Posts: 408
Founded: Jan 30, 2024
Authoritarian Democracy

Postby Daphomir » Thu Apr 04, 2024 8:48 pm

Dang this thread is old.
Now I am become Death, the Destroyer of Communism

NS Stats are protected by the people of Daphomir and are defended from the nations that seek to commit atrocities against them so horrible, it makes the Germans look like Good Samaritans


The Scare of April 14 still ongoing, increased anxiety rates reported in Daphomir City


A Class <14.66666667> Civilization according to this index.

User avatar
Kractero
Negotiator
 
Posts: 5172
Founded: May 08, 2011
Capitalist Paradise

Postby Kractero » Fri Apr 05, 2024 1:27 pm

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.

User avatar
Reiserland
Political Columnist
 
Posts: 2
Founded: Apr 20, 2023
Liberal Democratic Socialists

Postby Reiserland » Thu Apr 18, 2024 6:59 pm

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.
Last edited by Reiserland on Thu Apr 18, 2024 7:06 pm, edited 5 times in total.


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Ankuran, Buffalo-Bills, Countriopia, Deagarnia, Forwerpen, Graalstone, Grand Franistan, James_xenoland, Lushiania, Madrocea, New Yi Empire, Ravenol, Reventus Koth, Skiva, Yuspuize

Advertisement

Remove ads