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
Bureaucrat
 
Posts: 41
Founded: Feb 15, 2019
Authoritarian Democracy

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.

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.


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: The Koenigs Hof

Advertisement

Remove ads