Loka API

website·Indexed 31 days ago

https://api.lokamc.com/docs

Official documentation for the Loka API, providing access to publicly available data including players, towns, alliances, territories, and market data. Includes details on the API's data models, pagination, and rate limiting.

Tokens
3.9K
Snippets
24
Records
34
Agent score
53%

What's inside Loka API

  1. Town data model reference

    The Town model represents public information about a town. Key properties include:

    • id (string): MongoDB ObjectID of the player.
    • name (string): The Town Name.
    • strength (integer): Continent Conquest Strength.
    • bbStrength (integer): Balak Strength.
    • townLevel (integer): The Town Level.
    • recruiting (boolean): Whether the town is actively recruiting.
    • deleted (boolean): Whether the town has been deleted (dead).
    • owner (ObjectId): Identity ObjectId of the Player who owns the town.
    • vulnerabilityWindow (integer): The center hour of the 8-hour vulnerability window (Server Time). Add/subtract 4 hours from this value to get the full window. If the town is in an Alliance, the Alliance window is used instead.
    • world (string): Continent data-name: north (Kalros), west (Ascalon), or south (Garama).
    • bannerJson (string): Escaped JSON for the ItemStack representing the town's banner.
    • members (object): Town Members keyed by their identityId. Each member object contains id (Player ObjectId) and subowner (boolean).
  2. Understand the LokaMC Player model

    The Player model represents public information about a player on Loka. It includes the following properties:

    • id (string): The MongoDB ObjectID of the player.
    • identityId (ObjectId): A unique ID common across all a player's alternative accounts, representing a single person regardless of the Minecraft account used.
    • name (string): The in-game name. Note: This is updated only upon login and may differ from Mojang's API.
    • uuid (string): The Minecraft UUID of the player.
    • rank (string): The player's current rank.
    • discordId (integer): The ID of the player's linked Discord account.
  3. Territory Data Model

    The Territory model represents public information about a territory, including its location, ownership, and battle status.

    Properties:

    • id (string): The MongoDB ObjectID of the territory.
    • num (string): The territory number.
    • areaName (string): The data-name for the Biome this territory is in.
    • mutator (string): The current Mutator on the Territory.
    • world (string): The data-name of the Continent (north = Kalros, west = Ascalon, south = Garama).
    • tg (TerritoryGenerator): The associated Territory Generator object.
  4. Search for a territory by world and number

    Retrieve detailed information about a specific territory by providing its world identifier and territory number using the findByWorldAndNum endpoint. The response includes the territory's unique ID, area name, world, number, and a territory generator (tg) object containing beacon coordinates, town ID, module resource, and adjacent territory IDs.
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/territories/search/findByWorldAndNum', {
        params: { world: 'north', 'num': '2' }
    }).then((response) => console.log(response.data));
  5. Get started with the Loka API

    The Loka API provides access to publicly available data and information that can be discovered via in-game commands. To begin making requests, point your application to the base URL: https://api.lokamc.com. A request to the root URL will return a default response listing all available endpoints.
    curl https://api.lokamc.com
  6. Handle paginated responses in Loka API

    The Loka API supports pagination for all endpoints that return a list of objects. By default, 20 objects are returned per page. The maximum number of objects allowed in a single page is 20. Paginated responses nest the array of objects within an _embedded attribute and include a page object containing metadata about the current page and total results.
    "page": {
      "size": 20,
      "totalElements": 52576,
      "totalPages": 2629,
      "number": 0
    }
  7. List all towns

    Retrieve a paginated list of all towns using the /towns/search/findAll endpoint. You can optionally limit the results using size and page parameters.
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/towns/search/findAll', {
        params: { size: 20, page: 0 }
    })
        .then((response) => console.log(response.data));
  8. List buy orders by owner

    Retrieve all buy orders created by a specific player using their Identity ObjectId. Supports optional size and page parameters.
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/market_buyorder/search/findByOwnerId', {
        params: { id: '5462b7c5e4b0cad9a0f3e6a4' }
    }).then((response) => console.log(response.data));
  9. List all towns by world

    Retrieve a paginated list of all towns on a specific continent using the /towns/search/findByWorld endpoint. The world parameter is required and must be one of the continent data-names (e.g., north, west, south).
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/towns/search/findByWorld', {
        params: { world: 'north', size: 20, page: 0 }
    }).then((response) => console.log(response.data));
  10. Handle Loka API rate limiting

    The Loka API implements rate limiting to ensure service stability. When a request exceeds the rate limit, the API returns a response containing information regarding when the request tokens will refresh.
  11. List all active market sales

    Retrieve a list of all current sales on Loka. Supports optional pagination via size (limit) and page parameters.
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/market_sales')
    .then((response) => console.log(response.data));
  12. Find a player by UUID

    Retrieve a specific player's data by providing their Minecraft UUID via the GET /players/search/findByUuid endpoint. The uuid parameter is required.
    const axios = require('axios');
    
    axios.get('https://api.lokamc.com/players/search/findByUuid', {
        params: { uuid: 'b72542e7-3f35-4c29-9290-2b2032e9d98c' }
    }).then((response) => console.log(response.data));