NAV Navbar
shell

Introduction

Welcome to the Imperial Conflict API! You can use our API endpoints to retrieve information on various entities in our database.

You can view code examples in the dark area to the right.

Authentication

Imperial Conflict uses an API auth token to allow access to the API. This token is generated by passing API client credentials to an authentication endpoint. You can request these credentials by joining our Volunter Developers group.

Retrieving API Auth Token

Once you have your API client credentials, you can POST them to /ouath/token to retrieve your API auth token to be used for subsequent requests.

HTTP Request

POST https://api.imperialconflict.com/oauth/token

To retrieve an auth token, send your credentials with the following post body:

curl -v https://api.imperialconflict.com/oauth/token \
   -H "Accept: application/json" \
   -u "CLIENT_ID:CLIENT_SECRET" \
   -d "scope":"*" \
   -d "grant_type=client_credentials"

The above command returns JSON structured like this:

{
    "token_type": "Bearer",
    "expires_in": 31622400,
    "access_token": "API_AUTH_TOKEN"
}

Passing API Auth Token

Imperial Conflict expects for the API auth token to be included in all API requests to the server in a header that looks like the following:

To authorize, use this code:

curl "api_endpoint_here"
  -H "Authorization: Bearer API_AUTH_TOKEN"

Authorization: Bearer API_AUTH_TOKEN

Universe

Get Universe

This endpoint retrieves information about the Imperial Conflict universe.

HTTP Request

GET https://api.imperialconflict.com/universe

curl "https://api.imperialconflict.com/universe "
  -H "Authorization: Bearer API_AUTH_TOKEN"

The above command returns JSON structured like this:

{
  "name": "Imperial Conflict",
  "description": "Imperial Conflict is a free online browser-based massively multiplayer online strategy game set in space. Players interact in cooperation and against other players in a quest to \"Rule The Galaxy\".",
  "tags": [
    "space",
    "strategy",
    "military"
  ],
  "players": {
    "registered": 49387,
    "active": 248
  },
  "links": {
    "website": "https://imperialconflict.com",
    "forum": "https://discourse.imperialconflict.com",
    "discord": "https://discord.gg/yVZjc4M",
    "patreon": "https://www.patreon.com/imperialconflict",
    "facebook": "https://www.facebook.com/imperialconflict/",
    "twitter": "https://twitter.com/ic_game",
    "reddit": "https://www.reddit.com/r/ImperialConflict/",
    "pbbg.com": "https://pbbg.com/games/imperial-conflict",
    "PBBG Wiki": "https://wiki.pbbg.com/wiki/Imperial_Conflict"
  },
  "data": {
    "empires": {
      "active": 301
    },
    "galaxies": {
      "active": 4
    },
    "patreon_subscriber_credits": [
      "RUNIC",
      "Rivan",
      "Jets",
      "Ushanewnewba",
      "SCORP",
      "kingray",
      "Zeraph",
      "RenegadeDamon",
      "Goddess_of_the_Dead",
      "Tishxo",
      "Zeratel",
      "Usha"
    ]
  }
}

Galaxies

Get All Galaxies

This endpoint retrieves all galaxies.

HTTP Request

GET https://api.imperialconflict.com/galaxies

URL Parameters

Parameter Description
page An optional page number to retrieve items in sets of 20
curl "https://api.imperialconflict.com/galaxies"
  -H "Authorization: Bearer API_AUTH_TOKEN"

The above command returns JSON similar to below. The results have been shortened for readability:

{
    "data": [
        {
            "type": null,
            "id": "1",
            "attributes": {
                "name": "Milky Way",
                "slug": "milky-way",
                "short_name": "MW",
                "official": 1
            }
        },
        {
            "type": null,
            "id": "2",
            "attributes": {
                "name": "Andromeda",
                "slug": "andromeda",
                "short_name": "Andro",
                "official": 1
            }
        },
        {
            "type": null,
            "id": "21",
            "attributes": {
                "name": "Terra",
                "slug": "terra",
                "short_name": "terra",
                "official": 0
            }
        }
    ],
    "meta": {
        "pagination": {
            "total": 26,
            "count": 20,
            "per_page": 20,
            "current_page": 1,
            "total_pages": 2
        }
    },
    "links": {
        "self": "https://api.imperialconflict.com/galaxies?page=1",
        "first": "https://api.imperialconflict.com/galaxies?page=1",
        "next": "https://api.imperialconflict.com/galaxies?page=2",
        "last": "https://api.imperialconflict.com/galaxies?page=2"
    }
}

Get a Specific Galaxy

This endpoint retrieves a specific galaxy.

HTTP Request

GET https://api.imperialconflict.com/galaxies/<slug>

URL Parameters

Parameter Description
slug The slug (short-name) of the galaxy to retrieve
curl "https://api.imperialconflict.com/galaxies/milky-way"
  -H "Authorization: Bearer API_AUTH_TOKEN"

The above command returns JSON structured like this:

{
  "data": {
    "type": null,
    "id": "milky-way",
    "attributes": {
      "name": "Milky Way",
      "slug": "milky-way",
      "short_name": "MW",
      "official": 1
    }
  }
}

Empires

Get a Specific Empire

This endpoint retrieves a specific empire.

HTTP Request

GET https://api.imperialconflict.com/empires/id

URL Parameters

Parameter Description
ID The Empire ID
curl "https://api.imperialconflict.com/empires/383727"
  -H "Authorization: Bearer API_AUTH_TOKEN"

The above command returns JSON structured like this:

{
  "data": {
    "type": "empires",
    "id": "383727",
    "attributes": {
      "user_id": 102051,
      "name": "fearl3ss",
      "ruler": "Dron3s",
      "banner_filename": null,
      "family_id": 4291,
      "family_role_type_id": 2,
      "population": 743553,
      "planets_count": 85,
      "networth": 1149234,
      "home_planet_coordinates": {
        "x": 72,
        "y": 91,
        "number": 7
      }
    },
    "relationships": {
      "round": {
        "data": {
          "type": "rounds",
          "id": "23"
        }
      },
      "race": {
        "data": {
          "type": "races",
          "id": "621562"
        }
      }
    }
  },
  "included": [
    {
      "type": "rounds",
      "id": "23",
      "attributes": {
        "name": "Milky Way 56"
      }
    },
    {
      "type": "races",
      "id": "621562",
      "attributes": {
        "name": "CFO"
      }
    }
  ]
}

Errors

The Imperial Conflict API uses the following error codes:

Error Code Meaning
401 Unauthorized -- Your API auth token is invalid.
404 Not Found -- The specified resource could not be found.