npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

travian-kingdoms-api

v1.0.2

Published

JS Api for communication with travian kingdoms public (!!) endpoints

Downloads

7

Readme

Travian Kingdoms API npm version

JS Api for communication with travian kingdoms public (!!) endpoints.

What is public endpoint?

Endpoints for external tools published by travian kingdoms.

Functions

register

You need to call this first, to get an privateApiKey / publicSiteKey. With this privateApiKey you can make further calls to our api's.

Options

| Name | Type | Required | Meaning | | ------ | ------ | ------ | ------ | | url | String | yes | Server url like https://cz4.travian.com | | email | String (max 255) | yes | Needs to be a valid email | | siteName |String (max 255) | yes | Name of the tool | | siteUrl | String (max 255) | yes | Url of the tool - needs to be a valid url | | public | bool | yes |If you set it to true, that means we maybe include your tool in a tool list |

Example

const tka = require('travian-kingdoms-api')

tka.register(
	{
		url: 'https://cz4.kingdoms.com',
		email: '[email protected]',
		siteName: 'someSiteName',
		siteUrl: 'http://www.someSite.url',
		isPublic: 'true'
	},
	(err, response, body) => {
		/* handle err/response status if you want */
		console.log(body)
	}
)

Response

{
    time: 1524656411039,
    response: {
        privateApiKey: 'xxx',
        publicSiteKey: 'yyy'
    }
}

updateSiteData

You can call this if you want to update some data of your tool.

Options

| Name | Type | Required | Meaning | | ------ | ------ | ------ | ------ | | url | String | yes | Server url like https://cz4.travian.com | | privateApiKey | String | yes | Your private Api Key ( you retrieved via register function)| | email | String (max 255) | yes | Needs to be a valid email | | siteName |String (max 255) | yes | Name of the tool | | siteUrl | String (max 255) | yes | Url of the tool - needs to be a valid url | | public | bool | yes |If you set it to true, that means we maybe include your tool in a tool list |

Example

const tka = require('travian-kingdoms-api')

tka.updateSiteData(
	{
		privateApiKey: 'xxx',
		url: 'https://cz4.kingdoms.com',
		email: '[email protected]',
		siteName: 'someSiteName',
		siteUrl: 'http://www.someSite.url',
		isPublic: 'true'
	},
	(err, response, body) => {
		/* handle err/response status if you want */
		console.log(body)
	}
)

Response

{
    time: 1524656860998,
    response: {
        data: true
    }
}

getMapData

To get all public map data (old map.sql :-) ) from a specific date).

Options

| Name | Type | Required | Meaning | | ------ | ------ | ------ | ------ | | url | String | yes | Server url like https://cz4.travian.com | | privateApiKey | String | yes | Your private Api Key ( you retrieved via register function)| | date | String | no | Needs to be a date in format: d.m.Y (e.g. 27.08.2014). If no date is present, the today will be used. |

Example

const tka = require('travian-kingdoms-api')

tka.getMapData(
	{
		privateApiKey: 'xxx',
		url: 'https://cz4.kingdoms.com',
		date: '20.02.2018'
	},
	(err, response, body) => {
		/* handle err/response status if you want */
		console.log(body)
	}
)

Or without date:

const tka = require('travian-kingdoms-api')

tka.getMapData(
	{
		privateApiKey: 'xxx',
		url: 'https://cz4.kingdoms.com'
	},
	(err, response, body) => {
		/* handle err/response status if you want */
		console.log(body)
	}
)

Response

{
    time: 1524659209779,
    response: {
        gameworld: {
            name: 'cz4',
            startTime: 1518008400,
            speed: 1,
            speedTroops: 1,
            lastUpdateTime: '1519167901',
            date: 1519084800,
            version: '1.0' },
         players: [ ... ], //array of players
         kingdoms:[ ... ], //array of kingdoms
         map: {
            radius: '60',
            cells: [ ... ], //array of cells
            landscapes: [ ... ] //array of landscapes
        }
    }
}