FANDOM


Class Library Starter Kit Edit

A FOSS class library for accessing most of the APIs can be found here.

City Edit

using RestSharp;

namespace PoliticsAndWarAPIExamples
{
  public class CityAPI
  {
    private IRestClient _client;
    public CityAPI()
    {
      _client = new RestClient(@"https://politicsandwar.com/api");
    }

    public City GetCity(string cityId)
    {
      var request = new RestRequest($"/city/id={cityId}");
      request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
      IRestResponse<City> response = _client.Execute<City>(request);
      return response.Data;
    }
  }
  public class City
  {
    public bool success { get; set; }
    public string cityid { get; set; }
    public string url { get; set; }
    public string nationid { get; set; }
    public string name { get; set; }
    public string nation { get; set; }
    public string leader { get; set; }
    public string continent { get; set; }
    public string founded { get; set; }
    public int age { get; set; }
    public string powered { get; set; }
    public string infrastructure { get; set; }
    public string land { get; set; }
    public double population { get; set; }
    public double popdensity { get; set; }
    public int crime { get; set; }
    public double disease { get; set; }
    public int commerce { get; set; }
    public double avgincome { get; set; }
    public int pollution { get; set; }
    public int nuclearpollution { get; set; }
    public int basepop { get; set; }
    public double basepopdensity { get; set; }
    public double minimumwage { get; set; }
    public double poplostdisease { get; set; }
    public int poplostcrime { get; set; }
    public string imp_coalpower { get; set; }
    public string imp_oilpower { get; set; }
    public string imp_nuclearpower { get; set; }
    public string imp_windpower { get; set; }
    public string imp_coalmine { get; set; }
    public string imp_oilwell { get; set; }
    public string imp_ironmine { get; set; }
    public string imp_bauxitemine { get; set; }
    public string imp_leadmine { get; set; }
    public string imp_uramine { get; set; }
    public string imp_farm { get; set; }
    public string imp_gasrefinery { get; set; }
    public string imp_steelmill { get; set; }
    public string imp_aluminumrefinery { get; set; }
    public string imp_munitionsfactory { get; set; }
    public string imp_policestation { get; set; }
    public string imp_hospital { get; set; }
    public string imp_recyclingcenter { get; set; }
    public string imp_subway { get; set; }
    public string imp_supermarket { get; set; }
    public string imp_bank { get; set; }
    public string imp_mall { get; set; }
    public string imp_stadium { get; set; }
    public string imp_barracks { get; set; }
    public string imp_factory { get; set; }
    public string imp_hangar { get; set; }
    public string imp_drydock { get; set; }
  }
}

Nation Edit

using RestSharp;
using System.Collections.Generic;

namespace PoliticsAndWarAPIExamples
{
  public class NationAPI
  {
    private IRestClient _client;
    public NationAPI()
    {
      _client = new RestClient(@"https://politicsandwar.com/api");
    }

    public Nation GetNation(int id)
    {
      var request = new RestRequest($"/nation/id={id}");
      request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
      IRestResponse<Nation> response = _client.Execute<Nation>(request);
      return response.Data;
    }
  }
  public class Nation
  {
    public List<string> cityids { get; set; }
    public int cityprojecttimerturns { get; set; }
    public bool success { get; set; }
    public string nationid { get; set; }
    public string name { get; set; }
    public string prename { get; set; }
    public string continent { get; set; }
    public string socialpolicy { get; set; }
    public string color { get; set; }
    public int minutessinceactive { get; set; }
    public string uniqueid { get; set; }
    public string government { get; set; }
    public string domestic_policy { get; set; }
    public string war_policy { get; set; }
    public string founded { get; set; }
    public int daysold { get; set; }
    public string alliance { get; set; }
    public string allianceposition { get; set; }
    public string allianceid { get; set; }
    public string flagurl { get; set; }
    public string leadername { get; set; }
    public string title { get; set; }
    public string ecopolicy { get; set; }
    public string approvalrating { get; set; }
    public string nationrank { get; set; }
    public string nationrankstrings { get; set; }
    public int nrtotal { get; set; }
    public int cities { get; set; }
    public string latitude { get; set; }
    public string longitude { get; set; }
    public string score { get; set; }
    public string population { get; set; }
    public string gdp { get; set; }
    public int totalinfrastructure { get; set; }
    public int landarea { get; set; }
    public string soldiers { get; set; }
    public string soldiercasualties { get; set; }
    public string soldierskilled { get; set; }
    public string tanks { get; set; }
    public string tankcasualties { get; set; }
    public string tankskilled { get; set; }
    public string aircraft { get; set; }
    public string aircraftcasualties { get; set; }
    public string aircraftkilled { get; set; }
    public string ships { get; set; }
    public string shipcasualties { get; set; }
    public string shipskilled { get; set; }
    public string missiles { get; set; }
    public string missilelaunched { get; set; }
    public string missileseaten { get; set; }
    public string nukes { get; set; }
    public string nukeslaunched { get; set; }
    public string nukeseaten { get; set; }
    public string infdesttot { get; set; }
    public string infraLost { get; set; }
    public string moneyLooted { get; set; }
    public string ironworks { get; set; }
    public string bauxiteworks { get; set; }
    public string armsstockpile { get; set; }
    public string emgasreserve { get; set; }
    public string massirrigation { get; set; }
    public string inttradecenter { get; set; }
    public string missilelpad { get; set; }
    public string nuclearresfac { get; set; }
    public string irondome { get; set; }
    public string vitaldefsys { get; set; }
    public string intagncy { get; set; }
    public string uraniumenrich { get; set; }
    public string propbureau { get; set; }
    public string cenciveng { get; set; }
    public string vmode { get; set; }
    public int offensivewars { get; set; }
    public int defensivewars { get; set; }
    public List<string> offensivewar_ids { get; set; }
    public List<string> defensivewar_ids { get; set; }
    public int beige_turns_left { get; set; }
    public double radiation_index { get; set; }
    public string season { get; set; }
  }
}
Community content is available under CC-BY-SA unless otherwise noted.