Jump to content
Game-Labs Forum

Public "API" for Naval Action


Recommended Posts

Ok, I've found the issue - part of the data is not being exported. I will fix this in a next couple of weeks (most likely with a next content patch)

Sorry for messing things up

 

Today was a patch with new content, so may i asked if this will be updated also?

Link to comment
Share on other sites

Today was a patch with new content, so may i asked if this will be updated also?

Not yet.. Sorry

 

Next update will contain API update - more data available in Item Templates (full data about item templates) and UTF8 support

It should arrive with a next big update (from 10th to 15th of April)

  • Like 1
Link to comment
Share on other sites

Not yet.. Sorry

 

Next update will contain API update - more data available in Item Templates (full data about item templates) and UTF8 support

It should arrive with a next big update (from 10th to 15th of April)

Will the new API overwrite the existing data sources, or will it be backward-compatible?

Link to comment
Share on other sites

Indeed...

 

 

Here is a quick PHP function to transform this javascript declaration into proper JSON

 

returns null if something is wrong, or a PHP array containing datas from the "API"

	function fetchEndpoint($endpointUrl)
	{
		$content = file_get_contents($endpointUrl);
		if($content!==null && is_string($content))
		{
			$equalPos = strpos($content, '=');
			if($equalPos!==false)
				$content = trim(print_r(substr($content, $equalPos+1), true), ' ;');
			$JSON = json_decode($content,1);
			return $JSON;
		}
		return null;
	}
 Nice!

 

Since we're in a sharing-is-caring mood I implemented your function into an implicit Laravel controller :)

Edit: Made it a Gist instead of pasting it all here. https://gist.github.com/Sleavely/945939aec743ebe1b54ddc89b861493b

Edited by Svartschegg
Link to comment
Share on other sites

+1

Would love to have a Steam-based auth for logging in as your in-game character on clan forums and stuff.

 

+1

 

Yeah that would be nice, that would make all the polls about the direction the game should take in development become more trustworthy, I would for example love to see how many votes or voters on the "Player ship selection 1st half 2016 - Final Poll" comes from the same IP adress.

 
Link to comment
Share on other sites

Hello,

 

I just found this post. Is there currently in game support for plugins?

 

Edit: I would like to make the API here more real time. Is there an API on how to interact with Naval Action client from 3rd party addons? OK with the devs to create 3rd party addons ?

 

Edit2: Aside from experience, do you track user factions per steamID/Account?

Edited by Crayon
Link to comment
Share on other sites

Hello,

 

I just found this post. Is there currently in game support for plugins?

 

Edit: I would like to make the API here more real time. Is there an API on how to interact with Naval Action client from 3rd party addons? OK with the devs to create 3rd party addons ?

 

Edit2: Aside from experience, do you track user factions per steamID/Account?

The api is not real time data but data from the last maintenance.

Link to comment
Share on other sites

The api is not real time data but data from the last maintenance.

 

Yeah, I know. In that regard I don't understand why it cant be updated by users though. I could easily create my own database tables, make a simple web app from the given API, and allow updates that way. I think my Uni servers are still available to me... the only thing is I have no reliable, easy way to get the data from the game into a form on the web.

 

Even if I could just copy pasta chars into a form somehow I could get it to work!

Edited by Crayon
Link to comment
Share on other sites

Yeah, I know. In that regard I don't understand why it cant be updated by users though. I could easily create my own database tables, make a simple web app from the given API, and allow updates that way. I think my Uni servers are still available to me... the only thing is I have no reliable, easy way to get the data from the game into a form on the web.

Even if I could just copy pasta chars into a form somehow I could get it to work!

Do that on a separate host that you control. There is a much higher bar for accepting contributions to a central data set... to prevent data poisoning, denial of service, and just plain misinformation.

Link to comment
Share on other sites

Yeah I know how to authenticate with Steam, but Naval Action has a secondary, undocumented, layer of authentication that checks for the Steam token and also allows users to login with a user/pass combination that bypasses Steam. It is that secondary step of authentication that I suppose returns the list of "Captains" in your account.

To clarify with an example, my Steam username used to be "John", but my main captain in Naval Action is called "Svartschegg". I would like to retrieve "Svartschegg" from NA rather than "John" from Steam.

Edited by Svartschegg
  • Like 1
Link to comment
Share on other sites

Do that on a separate host that you control. There is a much higher bar for accepting contributions to a central data set... to prevent data poisoning, denial of service, and just plain misinformation.

 

Yeah I understand. It would require two seperate hosts with redundant data behind firewalls, and authentication ofc. Within my skillset, but let me tell ya, I hate double work =\

Link to comment
Share on other sites

database view, export/cache this in a xml and everyone is happy.

Split it up in:

data that changes frequently - market amounts, prices

data that changes only once a day - port ownership

data that changes only by patches - blueprint data, metadata of ports

Link to comment
Share on other sites

Ports ports attacks and leaderboards (if is set in the future) that arent in real time... :(

 

At least the ports and ports attacks

If you're on EU PVP3 you can query https://klr.nu/api/v2/port/{port_id} for a log of conquests. API docs: https://klr.nu/api/v2/docs#port

Sample response for Scarborough:

{
  "id":165,
  "nation_id":5,
  "name":"Scarborough",
  "capital":false,
  "regional":false,
  "shallow":false,
  "capturer_id":677,
  "timeslot":-1,
  "slug":"scarborough",
  "lat":"11.144213",
  "lng":"-60.775337",
  "updated_at":"2016-04-17 08:32:34",
  "nation":{
    "id":5,
    "name":"Verenigde Provinci\u00ebn",
    "max_bots":36,
    "updated_at":"2016-04-13 08:16:17"
  },
  "capturer":{
    "id":2,
    "name":"Svartschegg",
    "nation_id":7,
    "clan_id":24,
    "slug":"svartschegg",
    "created_at":"2016-01-18 00:00:00",
    "updated_at":"2016-04-12 13:41:52"
  },
  "production":[
    {
      "item_id":42,
      "quantity":4,
      "item":{
        "id":42,
        "name":"Silver",
        "type":"Resource",
        "updated_at":"2016-04-24 10:15:47"
      }
    }
  ],
  "consumption":[
    {
      "item_id":300,
      "quantity":48,
      "item":{
        "id":300,
        "name":"Live Oak Log",
        "type":"Resource",
        "updated_at":"2016-04-24 10:15:47"
      }
    }
  ],
  "shop":[
    {
      "item_id":27,
      "quantity":425,
      "buy_price":152,
      "sell_price":76,
      "contract_buy_quantity":-1,
      "contract_sell_quantity":-1,
      "updated_at":"2016-04-24 10:16:18",
      "item":{
        "id":27,
        "name":"Gold",
        "type":"Resource",
        "updated_at":"2016-04-24 10:15:47"
      }
    }
  ],
  "conquests":[ // 10 latest, regardless of contested (captured) or not
    {
      "id":1,
      "port_id":165,
      "nation_id"7,
      "player_id":2,
      "contested":true,
      "created_at":"2016-04-06 15:59:32",
      "updated_at":"2016-04-06 16:49:16",
      "nation":{
        "id":7,
        "name":"Sverige",
        "max_bots":36,
        "updated_at":"2016-04-05 05:53:50"
      },
      "player":{
        "id":2,
        "name":"Svartschegg",
        "nation_id":null,
        "clan_id":24,
        "slug":"svartschegg",
        "created_at":"2016-01-18 00:00:00",
        "updated_at":"2016-04-12 13:41:52"
      }
    }
  ]
}
Edit: API v2 Edited by Svartschegg
Link to comment
Share on other sites

×
×
  • Create New...