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: 45
Founded: Oct 17, 2014
Ex-Nation

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



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 Wed Jan 23, 2019 1:49 pm, edited 5 times in total.

User avatar
The United Island Tribes
Bureaucrat
 
Posts: 45
Founded: Oct 17, 2014
Ex-Nation

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: 45
Founded: Oct 17, 2014
Ex-Nation

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
Iron Fist Consumerists

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: 45
Founded: Oct 17, 2014
Ex-Nation

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: 45
Founded: Oct 17, 2014
Ex-Nation

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: 45
Founded: Oct 17, 2014
Ex-Nation

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: 1190
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.
COVID19 still exists! | Free time? Help Gutenberg!
The Labyrinth | GA Committee List | Tools written by me | NS Parliament 2: Zhang Xiaoqing

Admins: Please allow blocking WA TGs!
Fora
I've noticed that everybody that is for abortion has already been born. — Ronald Reagan

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

Compass E:-7.75 S:-3.64


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: No registered users

Advertisement

Remove ads