Socket
Socket
Sign inDemoInstall

nsapi

Package Overview
Dependencies
8
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nsapi

Provides access to the NationStates API


Version published
Weekly downloads
103
increased by157.5%
Maintainers
1
Install size
1.03 MB
Created
Weekly downloads
 

Changelog

Source

0.2.0 ##

  • Support API version 10

Readme

Source

nsapi

npm version

nsapi is a free and open source library that allows Node.js applications to easily access the NationStates API without worrying about making HTTP requests, decoding XML, caching or rate limiting.

nsapi features the following:

  • a complete interface to the NationStates API (supports the nation, region, world, World Assembly, telegram, trading cards, and authentication APIs)
  • rate-limiting to prevent blocked access to the API, including for the telegram API (recruitment and non-recruitment)
  • optional URI-based request caching
  • XML decoding (all data is returned in simple JavaScript data structures)
  • support for version 10 of the NationStates API

Usage

You can install nsapi using npm: npm install nsapi.

You can also build nsapi locally using npm: npm run-script build.

Consult the documentation for more information on API structure and methods.

nsapi targets ES5 but requires support for ES6 promises, so if you're not using a runtime that supports them natively, you'll have to use a polyfill.

Examples

The following is a simple example that retrieves a nation's full name and prints it to the console.

var nsapi = require("nsapi");

// TODO: Replace the user agent with your own
var api = new nsapi.NsApi("Your nation's name");
return api.nationRequest("Auralia", ["fullname"])
          .then(function(data) {
              console.log(data["fullname"]);
          })
          .then(function() {
              api.cleanup();
          });

For additional examples, consult the examples/example.js file.

License

nsapi is licensed under the Apache License 2.0.

Keywords

FAQs

Last updated on 18 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc