openapi: 3.0.3
info:
  title: Simco Tools API
  description: >
    This is the documentation page for the Simco Tools API. Here you can find
    all the information about the available endpoints in the API.


    There are two endpoints that might become your favorites—many of you have
    asked for a list of prices for all resources and qualities. Here you go:
    prices and VWAP ;)


    ## Considerations

    - Every endpoint is public: no API key or authentication is required.

    - All dates and timestamps are returned in UTC time, in RFC 3339 format.

    - There is a global rate limit of 2 requests per second with a burst of 25
    requests. Exceeding it returns `429 Too Many Requests`.

    - Monetary values and company values are returned as integers in the game
    currency, without decimals.

    - Fields that have no value are omitted from the response instead of being
    returned as `null`, so treat a missing field as "no data".

    - Paginated endpoints accept `page` and `page_size` (maximum 100) and return
    a `metadata` object. Some endpoints also accept `disable_pagination` to
    return the full list in a single response.

    - Sortable endpoints accept a `sort` query parameter. Prefixing the field
    with `-` sorts in descending order (for example `sort=-value`).


    If you have any questions or issues, please reach out to the support email.
    Also, if you find any errors in this documentation, let us know.
  contact:
    name: Simco Tools Support
    email: support@simcotools.com
  version: 1.0.0
servers:
  - url: "https://api.simcotools.com"
    description: Production server
security: []
tags:
  - name: Realms
    description: Realms, their daily summaries and their economic phases.
  - name: Constants
    description: Game constants available in a realm, such as resources and buildings.
  - name: Statistics
    description: Aggregated statistics calculated from the companies of a realm.
  - name: Companies
    description: Companies, their history, their ranking and their executives.
  - name: Market
    description: Prices, VWAPs, market summaries and candlesticks of the exchange.
  - name: Government orders
    description: Active and historical government orders of a realm.
  - name: Support
    description: Support tickets.
  - name: Service
    description: Status of the API and its own documentation.
paths:
  /v1/healthcheck:
    get:
      tags:
        - Service
      summary: Check the status of the API
      description: >-
        Returns the status of the API together with the environment it is
        running in and the version of the build serving the request.
      responses:
        "200":
          description: The API is available
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: available
                  systemInfo:
                    type: object
                    properties:
                      environment:
                        type: string
                        example: production
                      version:
                        type: string
                        description: Version of the build currently serving the API.
                        example: v1.4.2-0-g53e095a
        "429":
          $ref: "#/components/responses/TooManyRequests"
  /docs/simcotools.yaml:
    get:
      tags:
        - Service
      summary: Get this OpenAPI document
      description: >-
        Returns the OpenAPI document that describes the API. It is the same file
        that renders this documentation page.
      responses:
        "200":
          description: The OpenAPI document
          content:
            application/x-yaml:
              schema:
                type: string
  /docs/changelog.md:
    get:
      tags:
        - Service
      summary: Get the changelog of the API
      description: >-
        Returns the changelog of the API in Markdown, where every change in the
        endpoints and in the data they return is recorded.
      responses:
        "200":
          description: The changelog in Markdown format
          content:
            text/markdown:
              schema:
                type: string
  /v1/realms:
    get:
      tags:
        - Realms
      summary: Get all the realms in game.
      description: >-
        Get a list of ids of every realm in the game. This endpoint is useful to
        get the realm id to use in the other endpoints.
      parameters:
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: Successful response
          headers:
            Content-Language:
              $ref: "#/components/headers/Content-Language"
          content:
            application/json:
              schema:
                type: object
                properties:
                  realms:
                    type: array
                    items:
                      $ref: "#/components/schemas/realm"
        "404":
          description: There are no realms saved in the constants table of the database
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: there are no realms to show at the moment
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}":
    get:
      tags:
        - Realms
      summary: Get a realm status.
      description: >-
        Get a summary of the realm status. It returns the most recent daily
        summary available for the realm.
      parameters:
        - $ref: "#/components/parameters/realm"
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  summary:
                    $ref: "#/components/schemas/realmSummary"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: >-
            Realm not found, maybe the realm id is wrong or the realm is not in
            the database
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: the requested resource could not be found
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/summaries":
    get:
      tags:
        - Realms
      summary: Get a list of realms daily summaries.
      description: >-
        Get a list of daily summaries for the realm. The summaries are ordered
        by date in descending order by default.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - $ref: "#/components/parameters/since_date"
        - name: sort
          in: query
          description: >-
            Sort the list of summaries by the field specified. The default is
            `-date`. "-field" is for descending order.
          schema:
            type: string
            default: "-date"
            enum:
              - date
              - "-date"
              - active_companies
              - "-active_companies"
              - companies_value
              - "-companies_value"
              - total_buildings
              - "-total_buildings"
              - bonds_sold
              - "-bonds_sold"
              - completed
              - "-completed"
              - phase
              - "-phase"
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  summaries:
                    type: array
                    items:
                      $ref: "#/components/schemas/realmSummary"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/resources":
    get:
      tags:
        - Constants
      summary: Get a list of the resources availables in the realm
      description: >-
        Get the constants of every resource available in the realm according to
        the realm phase. The production per hour and the wages depend on the
        economic phase, so they are calculated for the phase requested in the
        `phase` parameter.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: type
          in: query
          description: Filter the resources by kind. The default is `all`.
          schema:
            type: string
            default: all
            enum:
              - all
              - tradeable
              - retail
              - research
        - name: produced_at
          in: query
          description: >-
            Returns only the resources produced at the building with this
            building id.
          schema:
            type: string
            example: "8"
        - name: sold_at
          in: query
          description: >-
            Returns only the resources sold at the building with this building
            id.
          schema:
            type: string
            example: s
        - $ref: "#/components/parameters/phase"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - $ref: "#/components/parameters/disable_pagination"
        - name: sort
          in: query
          description: >-
            Sort the list of resources by the field specified. The default is
            `name`. "-field" is for descending order.
          schema:
            type: string
            default: name
            enum:
              - id
              - "-id"
              - name
              - "-name"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: A list with the resources available in the realm
          content:
            application/json:
              schema:
                type: object
                properties:
                  resources:
                    type: array
                    items:
                      $ref: "#/components/schemas/resource"
                  type:
                    type: string
                    description: Filter applied
                    example: all
                  phase:
                    type: string
                    description: Economic phase used to calculate the values returned
                    example: normal
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/resources/{resource}":
    get:
      tags:
        - Constants
      summary: Get the info of a specific resource
      description: >-
        Get the constants of a specific resource in the realm, including its
        inputs and, when the resource is sold at retail, the retail information
        for every quality.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/phase"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The constants of the resource requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  resource:
                    $ref: "#/components/schemas/resource"
                  phase:
                    type: string
                    description: Economic phase used to calculate the values returned
                    example: normal
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/buildings":
    get:
      tags:
        - Constants
      summary: Get a list of buildings in the realm.
      description: >-
        Get a list of buildings in the realm according to the realm phase. The
        buildings can be filtered by type of building.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: type
          description: Filter for building type. Default is "all"
          in: query
          schema:
            type: string
            default: all
            enum:
              - all
              - production
              - sales
              - recreation
              - research
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - $ref: "#/components/parameters/disable_pagination"
        - name: sort
          in: query
          description: >-
            Sort the list of buildings by the field specified. The default is
            `name`. "-field" is for descending order.
          schema:
            type: string
            default: name
            enum:
              - id
              - "-id"
              - name
              - "-name"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: >-
            A list with the buildings available in the realm according to the
            realm phase
          content:
            application/json:
              schema:
                type: object
                properties:
                  buildings:
                    type: array
                    items:
                      $ref: "#/components/schemas/building"
                  type:
                    type: string
                    example: all
                    description: Filter applied
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/buildings/{building}":
    get:
      tags:
        - Constants
      summary: Get the constants of a specific building
      description: >-
        Get the constants of a specific kind of building in the realm, including
        the cost in units and the time needed to build one level.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/building"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The constants of the building requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  building:
                    $ref: "#/components/schemas/buildingConstants"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: >-
            The building was not found, maybe the building id is wrong or the
            building is not available yet in the phase of the realm
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: building not found
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/stats/buildings":
    get:
      tags:
        - Statistics
      summary: Get the number of every kind of building in the realm.
      description: >-
        Get a list with the number of every kind of buildings in the realm
        according to the active companies in the last ranking. It is updated
        every day when the data of all companies are fetched.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list by the field specified. The default is `-count`.
            "-field" is for descending order.
          schema:
            type: string
            default: "-count"
            enum:
              - count
              - "-count"
              - id
              - "-id"
              - name
              - "-name"
              - proportion
              - "-proportion"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: >-
            Returns a list with the number of every kind of buildings in the
            realm and the total buildings for all the companies.
          headers:
            Content-Language:
              $ref: "#/components/headers/Content-Language"
          content:
            application/json:
              schema:
                type: object
                properties:
                  buildings:
                    type: array
                    items:
                      $ref: "#/components/schemas/buildingCount"
                  totalBuildings:
                    type: integer
                    example: 325486
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/stats/countries":
    get:
      tags:
        - Statistics
      summary: Get the stats of the countries
      description: >-
        Get the number of companies and the sum of their values grouped by the
        country of the company, together with the three most valuable companies
        of every country. Only the companies updated in the last 2 days with a
        valid country are taken into account.


        The response also includes the country detected for the IP address that
        made the request, so a client can highlight the country of the visitor.
      parameters:
        - $ref: "#/components/parameters/realm"
      responses:
        "200":
          description: The stats of every country with companies in the realm
          content:
            application/json:
              schema:
                type: object
                properties:
                  countries:
                    type: object
                    description: >-
                      An object where every key is the 2-letter country code as
                      defined in the game.
                    additionalProperties:
                      $ref: "#/components/schemas/countryStats"
                  totalCompaniesWithCountry:
                    type: integer
                    description: >-
                      Total of companies taken into account to calculate the
                      stats.
                    example: 24863
                  requestCountryCode:
                    type: string
                    description: >-
                      Country code detected for the IP address of the request.
                      It is an empty string when it cannot be determined.
                    example: MX
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/phases":
    get:
      tags:
        - Realms
      summary: Get the economic phase ranges of the realm
      description: >-
        Get the list of periods the realm has spent in every economic phase,
        together with the stats of the days and the proportion of the time spent
        in each one. The stats are always calculated over the whole history
        available for the realm, even when the list is filtered or paginated.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - $ref: "#/components/parameters/since_date"
        - name: sort
          in: query
          description: >-
            Sort the list of ranges by the field specified. The default is
            `-end_date`. "-field" is for descending order.
          schema:
            type: string
            default: "-end_date"
            enum:
              - start_date
              - "-start_date"
              - end_date
              - "-end_date"
              - phase
              - "-phase"
              - days
              - "-days"
              - weeks
              - "-weeks"
      responses:
        "200":
          description: The phase ranges of the realm with their stats
          content:
            application/json:
              schema:
                type: object
                properties:
                  ranges:
                    type: array
                    items:
                      $ref: "#/components/schemas/phaseRange"
                  stats:
                    type: object
                    description: >-
                      Days and proportion of the time the realm has been in
                      every economic phase.
                    properties:
                      recession:
                        $ref: "#/components/schemas/phaseStats"
                      normal:
                        $ref: "#/components/schemas/phaseStats"
                      boom:
                        $ref: "#/components/schemas/phaseStats"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/phases/{date}":
    get:
      tags:
        - Realms
      summary: Get the economic phase of the realm for a specific date
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: date
          in: path
          required: true
          description: Date to look for, in `YYYY-MM-DD` format.
          schema:
            type: string
            format: date
            example: "2024-11-09"
      responses:
        "200":
          description: The economic phase of the realm in the date requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  realm:
                    type: integer
                    example: 0
                  phase:
                    type: string
                    example: recession
                    enum:
                      - recession
                      - normal
                      - boom
                  date:
                    type: string
                    format: date-time
                    example: "2024-11-09T00:00:00Z"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: There is no phase saved for the realm in the date requested
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: date not found
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/events":
    get:
      tags:
        - Realms
      summary: Get the random events of the realm
      description: >-
        Get the list of the random events of the realm. Every event modifies the
        production speed of one resource during a period of time.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: current
          in: query
          description: >-
            Returns only the events that are active at the moment of the
            request. The default is `false`.
          schema:
            type: boolean
            default: false
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list of events by the field specified. The default is
            `-id`. "-field" is for descending order.
          schema:
            type: string
            default: "-id"
            enum:
              - id
              - "-id"
              - resource_id
              - "-resource_id"
              - resource_name
              - "-resource_name"
              - speed_modifier
              - "-speed_modifier"
              - since
              - "-since"
              - until
              - "-until"
              - produced_at
              - "-produced_at"
              - produced_at_name
              - "-produced_at_name"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The list of the random events of the realm
          headers:
            Content-Language:
              $ref: "#/components/headers/Content-Language"
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items:
                      $ref: "#/components/schemas/event"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/contests":
    get:
      tags:
        - Realms
      summary: Get the contests of the realm
      description: >-
        Get the list of the contests of the realm, both the active and the
        historical ones. A contest is related either to a resource or to a kind
        of building.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: resource
          in: query
          description: Filters the contests by the id of the resource of the contest.
          schema:
            type: integer
            example: 1
        - name: building
          in: query
          description: Filters the contests by the id of the building of the contest.
          schema:
            type: string
            example: "8"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list of contests by the field specified. The default is
            `-id`. "-field" is for descending order.
          schema:
            type: string
            default: "-id"
            enum:
              - id
              - "-id"
              - name
              - "-name"
              - resource_id
              - "-resource_id"
              - resource_name
              - "-resource_name"
              - start_date
              - "-start_date"
              - end_date
              - "-end_date"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The list of the contests of the realm
          headers:
            Content-Language:
              $ref: "#/components/headers/Content-Language"
          content:
            application/json:
              schema:
                type: object
                properties:
                  contests:
                    type: array
                    items:
                      $ref: "#/components/schemas/contest"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/certificates":
    get:
      tags:
        - Companies
      summary: Get a list of all the kinds of cert availables in the realm
      description: >-
        Get the list of the kinds of certificates registered for the companies
        of the realm. Use the `kind` returned here to get the certificates of
        that kind.
      parameters:
        - $ref: "#/components/parameters/realm"
      responses:
        "200":
          description: The list of the kinds of certificates available in the realm
          content:
            application/json:
              schema:
                type: object
                properties:
                  realm:
                    type: integer
                    example: 0
                  certificates_kinds:
                    type: array
                    items:
                      $ref: "#/components/schemas/certificateKind"
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/certificates/{kind}":
    get:
      tags:
        - Companies
      summary: Get a list of the certificates filtered by kind
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: kind
          in: path
          required: true
          description: >-
            Kind of the certificate as assigned in the game. The available kinds
            can be obtained from the certificates endpoint.
          schema:
            type: integer
            example: 39
        - name: resource
          in: query
          description: >-
            Filters the certificates by the id of the resource related to the
            certificate, when the kind of certificate is related to a resource.
          schema:
            type: integer
            example: 1
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: Sort the list of certificates. Only `id` is accepted.
          schema:
            type: string
            default: id
            enum:
              - id
      responses:
        "200":
          description: The list of the certificates of the kind requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  certificates:
                    type: array
                    items:
                      $ref: "#/components/schemas/certificate"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/ranking":
    get:
      tags:
        - Companies
      summary: Get the ranking of the realm
      description: >-
        Get the ranking of the companies of the realm for a specific date,
        including the difference and the percentage of change of every value
        against the previous record of the company. When no date is sent, the
        last ranking calculated is returned.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: date
          in: query
          description: >-
            Date of the ranking in `YYYY-MM-DD` format. The default is the last
            ranking available.
          schema:
            type: string
            format: date
            example: "2024-11-09"
        - name: companies
          in: query
          description: >-
            Comma-separated list of company ids to return only the positions of
            those companies.
          schema:
            type: string
            example: 58463,58464
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the ranking by the field specified. The default is `rank`.
            "-field" is for descending order.
          schema:
            type: string
            default: rank
            enum:
              - rank
              - "-rank"
              - rank_diff
              - "-rank_diff"
              - eva_rank
              - "-eva_rank"
              - eva_rank_diff
              - "-eva_rank_diff"
              - name
              - "-name"
              - company_value
              - "-company_value"
              - company_value_diff
              - "-company_value_diff"
              - company_value_pct_change
              - "-company_value_pct_change"
              - buildings_value
              - "-buildings_value"
              - buildings_value_diff
              - "-buildings_value_diff"
              - buildings_value_pct_change
              - "-buildings_value_pct_change"
              - patents_value
              - "-patents_value"
              - patents_value_diff
              - "-patents_value_diff"
              - patents_value_pct_change
              - "-patents_value_pct_change"
              - workers
              - "-workers"
              - workers_diff
              - "-workers_diff"
              - workers_pct_change
              - "-workers_pct_change"
              - bonds_sold
              - "-bonds_sold"
              - bonds_sold_diff
              - "-bonds_sold_diff"
              - bonds_sold_pct_change
              - "-bonds_sold_pct_change"
      responses:
        "200":
          description: The ranking of the realm for the date requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  date:
                    type: string
                    format: date-time
                    description: Date of the ranking returned
                    example: "2024-11-09T00:00:00Z"
                  ranking:
                    type: array
                    items:
                      $ref: "#/components/schemas/rankingPosition"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/companies":
    get:
      tags:
        - Companies
      summary: Get a list of all the companies in the realm
      description: >-
        Get the list of the companies of the realm with the data of the last
        time every company was fetched. The list can be filtered by several
        fields of the company and by the buildings and the tags it has.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: name
          in: query
          description: >-
            Filters the companies by name. It matches any company whose name
            contains the value sent.
          schema:
            type: string
            example: Production Money
        - name: id
          in: query
          description: >-
            Comma-separated list of company ids to return only those companies.
          schema:
            type: string
            example: 58463,58464
        - name: building
          in: query
          description: >-
            Returns only the companies that have at least one building of this
            kind.
          schema:
            type: string
            example: "8"
        - name: tag_resource
          in: query
          description: >-
            Returns only the companies tagged with this resource id, in other
            words, the companies that buy or sell the resource.
          schema:
            type: integer
            example: 1
        - name: tag_kind
          in: query
          description: Returns only the companies whose tag is of this kind.
          schema:
            type: string
            enum:
              - buy
              - sell
        - name: year
          in: query
          description: Returns only the companies of this in-game year.
          schema:
            type: integer
            example: 12
        - name: level
          in: query
          description: Returns only the companies of this level.
          schema:
            type: integer
            example: 10
        - name: tier
          in: query
          description: Returns only the companies of this tier.
          schema:
            type: integer
            example: 3
        - name: rating
          in: query
          description: Returns only the companies with this rating.
          schema:
            type: string
            example: AAA
        - name: country
          in: query
          description: >-
            Returns only the companies of this country, using the 2-letter
            country code as defined in the game.
          schema:
            type: string
            example: MX
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list of companies by the field specified. The default is
            `-value`. "-field" is for descending order.
          schema:
            type: string
            default: "-value"
            enum:
              - id
              - "-id"
              - name
              - "-name"
              - level
              - "-level"
              - tier
              - "-tier"
              - year
              - "-year"
              - date_joined
              - "-date_joined"
              - date_reset
              - "-date_reset"
              - country
              - "-country"
              - rank
              - "-rank"
              - eva_rank
              - "-eva_rank"
              - rating
              - "-rating"
              - value
              - "-value"
              - administration_overhead
              - "-administration_overhead"
              - buildings_value
              - "-buildings_value"
              - total_buildings
              - "-total_buildings"
              - workers
              - "-workers"
              - patents_value
              - "-patents_value"
              - bonds_sold
              - "-bonds_sold"
              - building_value
              - "-building_value"
              - buildings
              - "-buildings"
              - tags
              - "-tags"
      responses:
        "200":
          description: The list of the companies of the realm
          content:
            application/json:
              schema:
                type: object
                properties:
                  companies:
                    type: array
                    items:
                      $ref: "#/components/schemas/company"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/companies/{company}":
    get:
      tags:
        - Companies
      summary: Get the data for specific company
      description: >-
        Get the data of a specific company with the values of the last time it
        was fetched, including the buildings and the tags of the company.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/company"
      responses:
        "200":
          description: The data of the company requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  company:
                    $ref: "#/components/schemas/company"
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/companies/{company}/history":
    get:
      tags:
        - Companies
      summary: Get the historical data for the company
      description: >-
        Get the historical records of the company, including the difference and
        the percentage of change of every value against the previous record of
        the period requested.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/company"
        - $ref: "#/components/parameters/period"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the history by the field specified. The default is `-date`.
            "-field" is for descending order.
          schema:
            type: string
            default: "-date"
            enum:
              - date
              - "-date"
              - rank
              - "-rank"
              - rank_diff
              - "-rank_diff"
              - eva_rank
              - "-eva_rank"
              - eva_rank_diff
              - "-eva_rank_diff"
              - value
              - "-value"
              - value_diff
              - "-value_diff"
              - value_pct_change
              - "-value_pct_change"
              - buildings_value
              - "-buildings_value"
              - buildings_value_diff
              - "-buildings_value_diff"
              - buildings_value_pct_change
              - "-buildings_value_pct_change"
              - patents_value
              - "-patents_value"
              - patents_value_diff
              - "-patents_value_diff"
              - patents_value_pct_change
              - "-patents_value_pct_change"
              - workers
              - "-workers"
              - workers_diff
              - "-workers_diff"
              - workers_pct_change
              - "-workers_pct_change"
              - bonds_sold
              - "-bonds_sold"
              - bonds_sold_diff
              - "-bonds_sold_diff"
              - bonds_sold_pct_change
              - "-bonds_sold_pct_change"
      responses:
        "200":
          description: The historical records of the company
          content:
            application/json:
              schema:
                type: object
                properties:
                  history:
                    type: array
                    items:
                      $ref: "#/components/schemas/companyHistory"
                  period:
                    type: string
                    description: Period applied
                    example: day
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/companies/{company}/chart":
    get:
      tags:
        - Companies
      summary: Get the historical data of the company ready to plot a chart
      description: >-
        Get the historical values of the company in a compact form, meant to
        feed a chart. Every record always includes the `date`, and the rest of
        the fields can be chosen with the `columns` parameter. A field is
        omitted in a record when there is no value saved for that date.


        When `start` and `end` are not sent, the range depends on the period:
        the last 30 days for `day`, the last 30 weeks for `week` and the last 12
        months for `month`.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/company"
        - $ref: "#/components/parameters/period"
        - name: columns
          in: query
          description: >-
            Comma-separated list of the fields to include in every record. When
            it is not sent, all the fields are returned.
          schema:
            type: string
            example: value,buildingsValue
        - name: start
          in: query
          description: Start of the range, as a Unix timestamp in milliseconds.
          schema:
            type: integer
            format: int64
            example: 1730937600000
        - name: end
          in: query
          description: End of the range, as a Unix timestamp in milliseconds.
          schema:
            type: integer
            format: int64
            example: 1733529600000
      responses:
        "200":
          description: The historical values of the company for the range requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/companyChartRecord"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/executives":
    get:
      tags:
        - Companies
      summary: Get the list of the executives in the realm
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: name
          in: query
          description: Filters the executives list by the name of the executive
          schema:
            type: string
        - name: position
          in: query
          description: Filters the executives list by position
          schema:
            type: string
            enum:
              - coo
              - cfo
              - cmo
              - cto
              - staff
        - name: company
          in: query
          description: Filters the executives list by the id of the current employer
          schema:
            type: integer
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list of executives by the field specified. The default is
            by id. "-field" is for descending order.
          schema:
            type: string
            default: id
            enum:
              - id
              - "-id"
              - name
              - "-name"
              - age
              - "-age"
              - position
              - "-position"
      responses:
        "200":
          description: Returns the list of executives in the realm
          content:
            application/json:
              schema:
                type: object
                properties:
                  executives:
                    type: array
                    items:
                      $ref: "#/components/schemas/executive"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/prices":
    get:
      tags:
        - Market
      summary: Get the price of the last trade of every resource and quality
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of all the values of the trades registered in the
            last 2 days
          content:
            application/json:
              schema:
                type: object
                properties:
                  prices:
                    type: array
                    items:
                      $ref: "#/components/schemas/price"
            text/csv:
              schema:
                type: string
                example: |
                  timestamp,resource,quality,price
                  2024-11-10T03:39:45Z,1,0,0.270000
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/prices/{resource}":
    get:
      tags:
        - Market
      summary: Get the price of the last trade of every quality for a specific resource
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of all the values of the trades registered in the
            last 2 days
          content:
            application/json:
              schema:
                type: object
                properties:
                  prices:
                    type: array
                    items:
                      $ref: "#/components/schemas/price"
            text/csv:
              schema:
                type: string
                example: |
                  timestamp,resource,quality,price
                  2024-11-10T03:39:45Z,1,0,0.270000
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/prices/{resource}/{quality}":
    get:
      tags:
        - Market
      summary: Get the price of the last trade for a specific resource and quality
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/quality"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of all the values of the trades registered in the
            last 2 days
          content:
            application/json:
              schema:
                type: object
                properties:
                  prices:
                    type: array
                    items:
                      $ref: "#/components/schemas/price"
            text/csv:
              schema:
                type: string
                example: |
                  timestamp,resource,quality,price
                  2024-11-10T03:39:45Z,1,0,0.270000
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/vwaps":
    get:
      tags:
        - Market
      summary: >-
        Get the last VWAP (Volume Weighted Average Price) calculated for every
        resource and quality
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of the last vwap calculated for every resource in the
            last 7 days.
          content:
            application/json:
              schema:
                type: object
                properties:
                  vwaps:
                    type: array
                    items:
                      $ref: "#/components/schemas/vwap"
            text/csv:
              schema:
                type: string
                example: |
                  date,resource,quality,vwap
                  2024-11-09T00:00:00Z,1,0,0.267851
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/vwaps/{resource}":
    get:
      tags:
        - Market
      summary: >-
        Get the last VWAP calculated for all the qualities of a specific
        resource
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of the last vwap calculated for an specific resource
            in the last 7 days.
          content:
            application/json:
              schema:
                type: object
                properties:
                  vwaps:
                    type: array
                    items:
                      $ref: "#/components/schemas/vwap"
            text/csv:
              schema:
                type: string
                example: |
                  date,resource,quality,vwap
                  2024-11-09T00:00:00Z,1,0,0.267851
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/vwaps/{resource}/{quality}":
    get:
      tags:
        - Market
      summary: Get the last VWAP calculated for a specific quality of the resource
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/quality"
        - $ref: "#/components/parameters/Accept"
      responses:
        "200":
          description: >-
            Returns a list of the last vwap calculated for the specific quality
            of the resource in the last 7 days.
          content:
            application/json:
              schema:
                type: object
                properties:
                  vwaps:
                    type: array
                    items:
                      $ref: "#/components/schemas/vwap"
            text/csv:
              schema:
                type: string
                example: |
                  date,resource,quality,vwap
                  2024-11-09T00:00:00Z,1,0,0.267851
        "400":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/followed":
    get:
      tags:
        - Market
      summary: Get the market summaries for a list of specific resources and qualities
      description: >-
        Get the market summary of an arbitrary list of pairs of resource and
        quality, which is useful to build a watchlist in a single request.
      parameters:
        - $ref: "#/components/parameters/realm"
        - name: resources
          in: query
          required: true
          description: >-
            Comma-separated list of pairs of resource and quality in the form
            `<resourceID>q<quality>`.
          schema:
            type: string
            example: 1q0,2q1,48q0
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The market summary of every pair of resource and quality requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  summaries:
                    type: array
                    items:
                      $ref: "#/components/schemas/marketSummary"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/resources/{resource}":
    get:
      tags:
        - Market
      summary: Get the market summaries for all the qualities of the resource
      description: >-
        Get the market summary of every quality traded for the resource,
        together with the random event affecting the resource when there is one
        active.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The market summaries of the resource
          content:
            application/json:
              schema:
                type: object
                properties:
                  resource:
                    $ref: "#/components/schemas/resourceSummary"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: >-
            The realm or the resource was not found, or there are no recent
            trades to show for the resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: No recent trades to show for this resource
        "422":
          description: >-
            The resource exists but it is not tradeable in the exchange
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/validationError"
              example:
                error:
                  resource: resource 25 is not tradeable
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/resources/{resource}/{quality}":
    get:
      tags:
        - Market
      summary: >-
        Get the market summary for a specific resource and quality in the realm
      description: >-
        Get the market summary of a specific resource and quality, including the
        last trade registered, the candlestick of the last five minutes, the
        candlestick of the last day and the historical daily closing prices.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/quality"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: The market summary of the resource and quality requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  summary:
                    $ref: "#/components/schemas/marketSummary"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: >-
            The realm or the resource was not found, or there are no recent
            trades to show
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: No recent trades to show
        "422":
          description: >-
            The resource exists but it is not tradeable in the exchange
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/validationError"
              example:
                error:
                  resource: resource 25 is not tradeable
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/market/resources/{resource}/{quality}/candlesticks":
    get:
      tags:
        - Market
      summary: Get the candlesticks data for a specific resource and quality
      description: >-
        Get the OHLCV (open, high, low, close, volume) data of the resource and
        quality for the granularity requested.


        Every granularity keeps a limited history, so when the `start` sent is
        older than the limit it is moved up to it: 7 days for `5m`, 30 days for
        `1h`, 180 days for `4h`, 365 days for `1d` and 4 years for `1W`. The
        granularity `1M` has no limit.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/resource"
        - $ref: "#/components/parameters/quality"
        - name: granularity
          in: query
          description: Size of the interval of every candlestick. The default is `1d`.
          schema:
            type: string
            default: 1d
            enum:
              - 5m
              - 1h
              - 4h
              - 1d
              - 1W
              - 1M
        - name: start
          in: query
          description: >-
            Start of the range, as a Unix timestamp in milliseconds. When it is
            not sent, the whole history available for the granularity is
            returned.
          schema:
            type: integer
            format: int64
            example: 1730937600000
        - name: end
          in: query
          description: End of the range, as a Unix timestamp in milliseconds.
          schema:
            type: integer
            format: int64
            example: 1733529600000
      responses:
        "200":
          description: The candlesticks of the resource and quality requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  candlesticks:
                    type: array
                    items:
                      $ref: "#/components/schemas/candlestick"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          description: The realm or the resource was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: resource 999 not found
        "422":
          description: >-
            The granularity is invalid or the resource is not tradeable in the
            exchange
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/validationError"
              example:
                error:
                  granularity: "must be one of: 1M, 1W, 1d, 4h, 1h, 5m"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  "/v1/realms/{realm}/government-orders":
    get:
      tags:
        - Government orders
      summary: >-
        Retrieve a list of government orders within the realm, including both
        active and historical orders.
      parameters:
        - $ref: "#/components/parameters/realm"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/page_size"
        - name: sort
          in: query
          description: >-
            Sort the list of government orders by the field specified. The
            default is by id desc. "-field" is for descending order.
          schema:
            type: string
            default: "-id"
            enum:
              - id
              - "-id"
              - project_name
              - "-project_name"
              - created_at
              - "-created_at"
              - days_to_fulfill
              - "-days_to_fulfill"
        - $ref: "#/components/parameters/Accept-Language"
      responses:
        "200":
          description: A list of government orders
          headers:
            Content-Language:
              $ref: "#/components/headers/Content-Language"
          content:
            application/json:
              schema:
                type: object
                properties:
                  orders:
                    type: array
                    items:
                      $ref: "#/components/schemas/governmentOrder"
                  metadata:
                    $ref: "#/components/schemas/metadata"
        "400":
          $ref: "#/components/responses/BadRequest"
        "422":
          $ref: "#/components/responses/ValidationFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
  /v1/support/tickets:
    post:
      tags:
        - Support
      summary: Create a support ticket
      description: >-
        Creates a support ticket. This is the endpoint used by the contact form
        of the site, so the ticket reaches the same place as an email to the
        support address.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ticket"
      responses:
        "201":
          description: The ticket was created
          content:
            application/json:
              schema:
                type: object
                properties:
                  ticket:
                    type: string
                    example: created
        "400":
          description: The body of the request is not valid JSON
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/error"
              example:
                error: body must not be empty
        "422":
          description: One or more fields of the ticket are missing or invalid
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/validationError"
              example:
                error:
                  email: a valid email address must be provided
                  message: must be provided
        "429":
          $ref: "#/components/responses/TooManyRequests"
components:
  parameters:
    realm:
      name: realm
      in: path
      required: true
      description: Realm ID
      schema:
        type: integer
        example: 0
    resource:
      name: resource
      in: path
      required: true
      description: Resource ID
      schema:
        type: integer
        example: 1
    quality:
      name: quality
      in: path
      required: true
      description: Quality of the resource
      schema:
        type: integer
        example: 1
    company:
      name: company
      in: path
      required: true
      description: Company ID
      schema:
        type: integer
        example: 58463
    building:
      name: building
      in: path
      required: true
      description: Building ID according to the game
      schema:
        type: string
        example: "8"
    page:
      name: page
      in: query
      description: "Page number, default is 1."
      schema:
        type: integer
        default: 1
        minimum: 1
        maximum: 10000000
        example: 1
    page_size:
      name: page_size
      in: query
      description: >-
        Page size, default is 50. The maximum is 100, unless the pagination is
        disabled with `disable_pagination`.
      schema:
        type: integer
        default: 50
        minimum: 1
        maximum: 100
        example: 50
    disable_pagination:
      name: disable_pagination
      in: query
      description: Allows to return all the results without pagination.
      schema:
        type: boolean
        default: false
        example: false
    since_date:
      name: since_date
      in: query
      description: >-
        Returns only the records from this date onwards, in `YYYY-MM-DD` format.
      schema:
        type: string
        format: date
        example: "2024-01-01"
    phase:
      name: phase
      in: query
      description: >-
        Economic phase used to calculate the values that depend on it. The
        default is `current`, which uses the phase the realm is in at the moment
        of the request.
      schema:
        type: string
        default: current
        enum:
          - current
          - recession
          - normal
          - boom
    period:
      name: period
      in: query
      description: >-
        Period of the records returned. With `week` only the records of Mondays
        are returned, and with `month` only the records of the first day of the
        month. The default is `day`.
      schema:
        type: string
        default: day
        enum:
          - day
          - week
          - month
    Accept-Language:
      name: Accept-Language
      in: header
      description: >-
        Language in which the names of the realms, buildings, or resources will
        be returned. If not present or if it is not an available language, the
        default language is English.
      schema:
        type: string
        default: en
        example: en
        enum:
          - es
          - en
          - de
          - pt
          - pl
          - tr
          - zh
          - fr
          - it
          - cs
          - ja
    Accept:
      name: Accept
      in: header
      description: >-
        Specifies the media type(s) that the client is willing to receive in the
        response. By setting this header, the client can indicate which content
        types are preferred, allowing the server to return data in the desired
        format. If not set, the server may return a default format (usually
        JSON).
      schema:
        type: string
        default: application/json
        example: application/json
        enum:
          - application/json
          - text/csv
  headers:
    Content-Language:
      description: >-
        Language in which the names of the realms, buildings or resources are
        returned
      schema:
        type: string
        example: en
        enum:
          - es
          - en
          - de
          - pt
          - pl
          - tr
          - zh
          - fr
          - it
          - cs
          - ja
  responses:
    BadRequest:
      description: >-
        One of the parameters in the path is not valid, for example when an id
        is not a positive number
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/error"
          example:
            error: invalid realm parameter, must be a positive number
    NotFound:
      description: The resource requested was not found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/error"
          example:
            error: the requested resource could not be found
    ValidationFailed:
      description: >-
        One or more of the query parameters are not valid. The `error` field
        holds an object where every key is the parameter that failed.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/validationError"
          example:
            error:
              page_size: must be a maximum of 100
              sort: invalid sort value
    TooManyRequests:
      description: >-
        The rate limit of 2 requests per second, with a burst of 25 requests,
        was exceeded
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/error"
          example:
            error: rate limit exceeded
  schemas:
    realm:
      type: object
      title: Realm
      properties:
        id:
          type: integer
          description: Realm ID
          example: 1
        name:
          type: string
          description: Realm name in the language requested
          example: Magnates
      example:
        id: 0
        name: Magnates
    realmSummary:
      type: object
      title: Realm Summary
      properties:
        date:
          type: string
          format: date-time
          example: "2024-06-28T00:00:00Z"
        activeCompanies:
          type: integer
          description: >-
            Number of companies of the realm that were active in the current
            date.
          example: 27131
        companiesValue:
          type: integer
          format: int64
          description: Sum of the values of the active companies in the realm.
          example: 1136868083977
        totalBuildings:
          type: integer
          example: 296598
          description: >-
            Total of buildings of the active companies in the realm in the
            current date. This value is calculated once all the companies data
            is fetched.
        bondsSold:
          type: integer
          format: int64
          example: 21475020000
          description: >-
            Sum of all bonds sold in the realm in the current date. This value
            is calculated once all the companies data is fetched.
        phase:
          type: string
          description: Economic phase of the realm in the current date.
          example: recession
          enum:
            - recession
            - normal
            - boom
        completed:
          type: boolean
          example: true
          description: >-
            Indicate if the realm data is completed calculated or not, if not,
            the data for the totalBuildings and bondsSold are for the day
            before the date in the response.
      example:
        date: "2024-06-28T00:00:00Z"
        activeCompanies: 27131
        companiesValue: 1136868083977
        totalBuildings: 296598
        bondsSold: 21475020000
        phase: recession
        completed: true
    phaseRange:
      type: object
      title: Phase Range
      description: A period of time the realm has spent in one economic phase
      properties:
        phase:
          type: string
          example: boom
          enum:
            - recession
            - normal
            - boom
        start:
          type: string
          format: date-time
          description: First date of the realm in this phase
          example: "2024-10-07T00:00:00Z"
        end:
          type: string
          format: date-time
          description: Last date of the realm in this phase
          example: "2024-11-03T00:00:00Z"
        days:
          type: integer
          description: Number of days the realm was in this phase
          example: 28
        weeks:
          type: integer
          description: Number of complete weeks the realm was in this phase
          example: 4
    phaseStats:
      type: object
      title: Phase Stats
      description: Days and proportion of the time the realm has been in one phase
      properties:
        days:
          type: integer
          example: 364
        percentage:
          type: number
          format: float
          description: Proportion of the total days, from 0 to 1.
          example: 0.3333
    building:
      type: object
      title: Building
      properties:
        id:
          description: The id of the building according to the game.
          type: string
          example: "8"
        name:
          description: The name of the building returned in the language requested.
          type: string
          example: Aerospace electronics
      example:
        id: "8"
        name: Aerospace electronics
    buildingConstants:
      type: object
      title: Building Constants
      description: The constants of a kind of building
      properties:
        id:
          description: The id of the building according to the game.
          type: string
          example: "8"
        name:
          description: The name of the building returned in the language requested.
          type: string
          example: Aerospace electronics
        costUnits:
          description: Cost in units of building one level of this building.
          type: integer
          example: 7000
        buildDuration:
          description: Hours needed to build one level of this building.
          type: integer
          example: 24
      example:
        id: "8"
        name: Aerospace electronics
        costUnits: 7000
        buildDuration: 24
    buildingCount:
      type: object
      title: Building Counter
      properties:
        id:
          description: The id of the building according to the game.
          type: string
          example: "8"
        name:
          type: string
          description: The name of the building returned in the language requested.
          example: Aerospace electronics
        count:
          description: The number of slots with this kind of building in the realm.
          type: integer
          example: 479
        proportion:
          description: >-
            Proportion of the quantity of this building according to the total
            buildings in the realm.
          type: number
          format: float
          example: 0.015
    resource:
      type: object
      title: Resource
      properties:
        id:
          description: Resource ID according to the game.
          type: integer
          example: 1
        name:
          description: Name of the resource in the language requested.
          type: string
          example: Power
        isResearch:
          description: Is true when the resource is a research resource.
          type: boolean
          example: false
        transportation:
          description: Transportation units needed to move one unit of the resource.
          type: number
          format: float
          example: 0
        producedAnHour:
          description: >-
            Units produced an hour by one level of the building that produces
            the resource, already adjusted for the economic phase requested and
            for any active random event.
          type: number
          format: float
          example: 1526.4
        speedModifier:
          description: >-
            Percentage the production speed of the resource is modified by an
            active random event. It is omitted when there is no event.
          type: integer
          example: 20
        wages:
          description: Wages paid an hour by one level of the building.
          type: number
          format: float
          example: 1.6
        inputs:
          type: object
          description: >-
            Resources needed to produce one unit of this resource. Every key is
            the id of the input resource.
          additionalProperties:
            type: object
            properties:
              name:
                type: string
                example: Water
              quantity:
                type: number
                format: float
                example: 0.5
          example:
            "12":
              name: Water
              quantity: 0.5
        retailInfo:
          type: array
          description: >-
            Retail information for every quality of the resource. It is only
            returned for the resources that have a retail model.
          items:
            $ref: "#/components/schemas/retailInfo"
    retailInfo:
      type: object
      title: Retail Info
      description: Modeled retail information for one quality of a resource
      properties:
        quality:
          type: integer
          example: 0
        buildingLevelsNeededPerUnitPerHour:
          type: number
          format: float
          example: 0.0025
        modeledProductionCostPerUnit:
          type: number
          format: float
          example: 0.21
        modeledStoreWages:
          type: number
          format: float
          example: 1.2
        modeledUnitsSoldAnHour:
          type: number
          format: float
          example: 400.5
        retailModelingQualityWeight:
          type: number
          format: float
          example: 0.5
        profitPerBuildingLevel:
          type: integer
          example: 100
        retailAdjustment:
          type: number
          format: float
          example: 1.05
        averagePrice:
          description: Average retail price of this quality in the realm.
          type: number
          format: float
          example: 1.86
        saturation:
          description: Saturation of the retail market for this quality in the realm.
          type: number
          format: float
          example: 0.78
        salesWages:
          description: Wages paid an hour by one level of the building that sells it.
          type: number
          format: float
          example: 1.6
    event:
      type: object
      title: Event
      properties:
        id:
          type: integer
          example: 124
        resource:
          type: integer
          example: 1
          description: Resource ID of the resource affected for the event
        resourceName:
          type: string
          example: Power
          description: >-
            Resource name of the resource affected for the event returned in the
            language requested
        speedModifier:
          type: integer
          description: >-
            Percentage the production speed of the resource is modified by the
            event. It is negative when the event slows the production down.
          example: 20
        since:
          type: string
          format: date-time
          example: "2024-11-09T00:00:00Z"
        until:
          type: string
          format: date-time
          example: "2024-11-16T00:00:00Z"
        producedAt:
          type: string
          description: Building ID where the resource affected is produced
          example: "1"
        producedAtName:
          type: string
          description: >-
            Building name where the resource affected is produced returned in
            the requested language
          example: Power plant
    contest:
      type: object
      title: Contest
      properties:
        id:
          type: integer
          example: 312
        name:
          type: string
          description: Name of the contest
          example: Power production contest
        resourceId:
          type: integer
          description: >-
            Resource ID of the resource of the contest, when the contest is
            about a resource.
          example: 1
        resourceName:
          type: string
          description: Name of the resource in the language requested
          example: Power
        buildingId:
          type: string
          description: >-
            Building ID of the building of the contest, when the contest is
            about a kind of building.
          example: "8"
        buildingName:
          type: string
          description: Name of the building in the language requested
          example: Aerospace electronics
        startDate:
          type: string
          format: date-time
          example: "2024-11-09T00:00:00Z"
        endDate:
          type: string
          format: date-time
          example: "2024-11-16T00:00:00Z"
    countryStats:
      title: Country Stats
      type: object
      properties:
        country_code:
          type: string
          description: 2-letter country code as defined in the game
          example: MX
        total_companies:
          type: integer
          example: 412
        total_companies_value:
          type: integer
          format: int64
          example: 15486203114
        rank:
          type: array
          description: The three most valuable companies of the country
          items:
            $ref: "#/components/schemas/company"
    certificateKind:
      type: object
      title: Certificate Kind
      properties:
        kind:
          type: integer
          description: The kind of the certificate assigned in the game
          example: 39
        relevant:
          type: boolean
          description: >-
            Is true if the cert is one of the most searched certificates for the
            players
          example: true
        resources:
          type: array
          description: >-
            If apply this shows a list of the resources related to the
            certificate kind
          items:
            type: integer
          example:
            - 1
            - 2
            - 3
            - 4
    certificate:
      type: object
      title: Certificate
      properties:
        id:
          type: integer
          example: 22351
          description: ID of the certificate assigned for the game
        companyId:
          type: integer
          example: 858585
          description: ID of the company owner of the certificate
        companyName:
          type: string
          example: Production Money
        resourceKind:
          type: integer
          description: When apply it shows the resource ID related to the certificate
          example: 1
        certInfo:
          type: object
          description: >-
            Extra information of the certificate as it is registered in the
            game. Its fields depend on the kind of the certificate.
          additionalProperties: true
        date:
          type: object
          description: an object for represent the date information of the certificate.
          properties:
            week:
              type: integer
              description: the number of the week the certificate was issued
              example: 3
            month:
              type: integer
              description: >-
                the number of the month from 1 to 13 when the certificate was
                issued
              example: 1
            year:
              type: integer
              description: the year in format yyyy when the certificate was issued
              example: 2024
    company:
      type: object
      title: Company
      description: >-
        The data of a company with the values of the last time it was fetched
      properties:
        id:
          type: integer
          description: Company ID as used in the game
          example: 58463
        realm:
          type: integer
          example: 0
        name:
          type: string
          example: Production Money
        logo:
          type: string
          description: Path of the logo of the company in the game
          example: /static/logos/58463.png
        level:
          type: integer
          example: 10
        tier:
          type: integer
          example: 3
        year:
          type: integer
          description: In-game year of the company
          example: 12
        dateJoined:
          type: string
          format: date-time
          example: "2021-03-14T00:00:00Z"
        dateReset:
          type: string
          format: date-time
          example: "2023-07-01T00:00:00Z"
        country:
          type: string
          description: As defined in the game, 2-letter country codes
          example: MX
        rank:
          type: integer
          example: 142
        evaRank:
          type: integer
          description: Position of the company in the EVA Rank
          example: 97
        rating:
          type: string
          example: AAA
        value:
          type: integer
          format: int64
          example: 4863201147
        buildingValue:
          type: integer
          example: 1256300000
        totalBuildings:
          type: integer
          description: >-
            Total number of buildings calculated from the buildings list of the
            company
          example: 48
        workers:
          type: integer
          description: Total number of building levels of the company
          example: 1240
        administrationOverhead:
          type: number
          format: float
          example: 0.12
        patentsValue:
          type: integer
          format: int64
          example: 158000000
        bondsSold:
          type: integer
          example: 750000000
        buildings:
          type: object
          description: >-
            Number of slots the company has of every kind of building. Every key
            is the building id.
          additionalProperties:
            type: integer
          example:
            "8": 12
            s: 4
        tags:
          type: object
          description: >-
            Tags of the company. Every key is the resource id and the value is
            the kind of the tag.
          additionalProperties:
            type: string
          example:
            "1": sell
            "12": buy
        updatedAt:
          type: string
          format: date-time
          description: Last time the data of the company was fetched
          example: "2024-11-10T03:39:45Z"
    companyHistory:
      type: object
      title: Company History
      description: >-
        One historical record of a company with the difference and the
        percentage of change against the previous record of the period
      properties:
        date:
          type: string
          format: date-time
          example: "2024-11-09T00:00:00Z"
        rank:
          type: integer
          example: 142
        rankDiff:
          type: integer
          example: -3
        evaRank:
          type: integer
          example: 97
        evaRankDiff:
          type: integer
          example: 1
        value:
          type: integer
          format: int64
          example: 4863201147
        valueDiff:
          type: integer
          format: int64
          example: 12500000
        valuePctChange:
          type: number
          format: float
          example: 0.0026
        buildingsValue:
          type: integer
          example: 1256300000
        buildingsValueDiff:
          type: integer
          example: 3200000
        buildingsValuePctChange:
          type: number
          format: float
          example: 0.0026
        patentsValue:
          type: integer
          format: int64
          example: 158000000
        patentsValueDiff:
          type: integer
          format: int64
          example: 0
        patentsValuePctChange:
          type: number
          format: float
          example: 0
        workers:
          type: integer
          example: 1240
        workersDiff:
          type: integer
          example: 15
        workersPctChange:
          type: number
          format: float
          example: 0.0122
        bondsSold:
          type: integer
          example: 750000000
        bondsSoldDiff:
          type: integer
          example: 0
        bondsSoldPctChange:
          type: number
          format: float
          example: 0
        fetched:
          type: boolean
          description: >-
            Is true when the data of the company was fetched for this date. When
            it is false the record was built from the ranking only.
          example: true
    companyChartRecord:
      type: object
      title: Company Chart Record
      description: >-
        One record of the historical values of a company. Only the `date` is
        always present; the other fields depend on the `columns` requested and
        on the data available for the date.
      properties:
        date:
          type: string
          format: date-time
          example: "2024-11-09T00:00:00Z"
        value:
          type: integer
          format: int64
          example: 4863201147
        buildingsValue:
          type: integer
          format: int64
          example: 1256300000
        patentsValue:
          type: integer
          format: int64
          example: 158000000
        bondsSold:
          type: integer
          format: int64
          description: >-
            Bonds sold by the company, returned as a negative number so it can
            be plotted below the axis.
          example: -750000000
    rankingPosition:
      type: object
      title: Ranking Position
      description: >-
        One position of the ranking with the difference and the percentage of
        change of every value against the previous record of the company
      properties:
        companyId:
          type: integer
          example: 58463
        companyName:
          type: string
          example: Production Money
        rank:
          type: integer
          example: 142
        rankDiff:
          type: integer
          example: -3
        evaRank:
          type: integer
          example: 97
        evaRankDiff:
          type: integer
          example: 1
        companyValue:
          type: integer
          format: int64
          example: 4863201147
        companyValueDiff:
          type: integer
          format: int64
          example: 12500000
        companyValuePctChange:
          type: number
          format: float
          example: 0.0026
        buildingsValue:
          type: integer
          example: 1256300000
        buildingsValueDiff:
          type: integer
          example: 3200000
        buildingsValuePctChange:
          type: number
          format: float
          example: 0.0026
        patentsValue:
          type: integer
          format: int64
          example: 158000000
        patentsValueDiff:
          type: integer
          format: int64
          example: 0
        patentsValuePctChange:
          type: number
          format: float
          example: 0
        workers:
          type: integer
          example: 1240
        workersDiff:
          type: integer
          example: 15
        workersPctChange:
          type: number
          format: float
          example: 0.0122
        bondsSold:
          type: integer
          example: 750000000
        bondsSoldDiff:
          type: integer
          example: 0
        bondsSoldPctChange:
          type: number
          format: float
          example: 0
        daysSinceLastValuation:
          type: integer
          description: >-
            Days passed since the last time the company was valued in the game.
          example: 1
        isDeleted:
          type: boolean
          description: Is true when the company no longer exists in the game.
          example: false
        fetched:
          type: boolean
          description: >-
            Is true when the data of the company was fetched for this ranking.
          example: true
    executive:
      type: object
      title: Executive
      description: The data available for executives
      properties:
        id:
          type: integer
          description: The id of the executive in the game
          example: 4963694
        name:
          type: string
          description: The name of the executive
          example: Roland Hefford
        age:
          type: integer
          description: The age of the executive
          example: 62
        position:
          type: string
          description: "The kind of the Executive: coo, cfo, cmo, cto, staff"
          example: coo
          enum:
            - coo
            - cfo
            - cmo
            - cto
            - staff
        currentEmployer:
          type: object
          description: Info of the company where the executive works
          properties:
            id:
              type: integer
              description: The id of the company
              example: 2584035
            name:
              type: string
              description: The name of the company
              example: Production Money
    price:
      type: object
      title: Price
      description: Represents the data for the last trade registered in the last 2 days
      properties:
        datetime:
          type: string
          format: date-time
          description: The timestamp of the last trade in valid RFC 3339 format
          example: "2024-11-10T03:39:45.067352Z"
        resourceId:
          type: integer
          description: The ID of the resource
          example: 1
        quality:
          type: integer
          description: The quality of the resource
          example: 0
        price:
          type: number
          format: float
          description: The value of the trade
          example: 0.27
    vwap:
      type: object
      title: VWAP
      description: Represents the data for the last vwap calculated in the last 7 days
      properties:
        datetime:
          type: string
          format: date-time
          description: The date of the last vwap calculated in valid RFC 3339 format
          example: "2024-11-09T00:00:00Z"
        resourceId:
          type: integer
          description: The ID of the resource
          example: 1
        quality:
          type: integer
          description: The quality of the resource
          example: 0
        vwap:
          type: number
          format: float
          description: The vwap value
          example: 0.26785144
    candlestick:
      type: object
      title: Candlestick
      description: >-
        The OHLCV data of one interval for a resource and quality. A field is
        omitted when its value is zero.
      properties:
        date:
          type: string
          format: date-time
          description: Start of the interval of the candlestick
          example: "2024-11-09T00:00:00Z"
        open:
          type: number
          format: float
          example: 0.27
        high:
          type: number
          format: float
          example: 0.29
        low:
          type: number
          format: float
          example: 0.26
        close:
          type: number
          format: float
          example: 0.28
        volume:
          type: integer
          format: int64
          description: Units traded during the interval
          example: 1548963
        vwap:
          type: number
          format: float
          description: Volume weighted average price of the interval
          example: 0.26785144
        previousCloseDifference:
          type: number
          format: float
          description: Difference between this close and the close of the previous interval
          example: 0.01
        previousClosePercentageChange:
          type: number
          format: float
          description: Percentage of change against the close of the previous interval
          example: 3.7
        previousVWAPDifference:
          type: number
          format: float
          description: Difference between this vwap and the vwap of the previous interval
          example: 0.008
        previousVWAPPercentageChange:
          type: number
          format: float
          description: Percentage of change against the vwap of the previous interval
          example: 3.1
    marketSummary:
      type: object
      title: Market Summary
      description: The state of the market for one resource and quality
      properties:
        realmId:
          type: integer
          example: 0
        resourceId:
          type: integer
          example: 1
        resourceName:
          type: string
          description: Name of the resource in the language requested
          example: Power
        quality:
          type: integer
          example: 0
        timestamp:
          type: string
          format: date-time
          description: Timestamp of the last trade registered
          example: "2024-11-10T03:39:45.067352Z"
        price:
          type: number
          format: float
          description: Price of the last trade registered
          example: 0.27
        volume:
          type: integer
          description: Units traded in the last day
          example: 1548963
        priceDifference:
          type: number
          format: float
          description: Difference against the closing price of the previous day
          example: 0.01
        pricePercentChange:
          type: number
          format: float
          description: Percentage of change against the closing price of the previous day
          example: 3.7
        fiveMinutesCandlestick:
          $ref: "#/components/schemas/candlestick"
        lastDayCandlestick:
          $ref: "#/components/schemas/candlestick"
        historicalDailyClosingPrices:
          type: array
          description: Closing price of every one of the last days
          items:
            $ref: "#/components/schemas/historicalClosePrice"
        latestClosePrices:
          type: array
          description: Closing price of every one of the latest intervals of the day
          items:
            $ref: "#/components/schemas/historicalClosePrice"
    resourceSummary:
      type: object
      title: Resource Summary
      description: The state of the market for every quality of one resource
      properties:
        realmId:
          type: integer
          example: 0
        resourceId:
          type: integer
          example: 1
        resourceName:
          type: string
          description: Name of the resource in the language requested
          example: Power
        qualities:
          type: array
          description: Qualities of the resource with trades registered
          items:
            type: integer
          example:
            - 0
            - 1
            - 2
        summariesByQuality:
          type: array
          items:
            $ref: "#/components/schemas/marketSummary"
        event:
          allOf:
            - $ref: "#/components/schemas/event"
          description: >-
            The random event affecting the resource, when there is one active.
    historicalClosePrice:
      type: object
      title: Historical Close Price
      properties:
        datetime:
          type: string
          format: date-time
          example: "2024-11-09T00:00:00Z"
        closePrice:
          type: number
          format: float
          example: 0.28
    governmentOrder:
      title: Government Order
      type: object
      properties:
        id:
          type: integer
          example: 41
        projectName:
          type: string
          description: Name of the project in the language requested
          example: Engines Tests
        daysToFulfill:
          type: integer
          example: 3
        created:
          type: string
          format: date-time
          example: "2024-11-27T13:00:45.85922Z"
        resources:
          type: array
          items:
            type: object
            properties:
              resourceId:
                type: integer
                example: 48
              quality:
                type: integer
                example: 0
              resourceName:
                type: string
                example: Electric motor
          example:
            - resourceId: 48
              quality: 0
              resourceName: Electric motor
            - resourceId: 52
              quality: 0
              resourceName: Combustion engine
    ticket:
      type: object
      title: Ticket
      required:
        - email
        - name
        - subject
        - message
      properties:
        email:
          type: string
          format: email
          description: Email address to answer the ticket
          example: player@example.com
        name:
          type: string
          example: Ricardo
        subject:
          type: string
          example: Wrong price in the prices endpoint
        message:
          type: string
          example: The price of power in realm 0 looks outdated.
        topicId:
          type: integer
          description: Id of the topic of the ticket in the support system
          example: 3
        attachments:
          type: array
          description: >-
            Files attached to the ticket. Every item is an object of strings as
            expected by the support system.
          items:
            type: object
            additionalProperties:
              type: string
          example:
            - filename: screenshot.png
              url: https://example.com/screenshot.png
    metadata:
      type: object
      title: Metadata
      description: >-
        Metadata attached in almost all responses, includes pagination
        information. Every field is omitted when the query returns no records.
      properties:
        currentPage:
          type: integer
          description: Current page for the current query
          example: 1
        pageSize:
          type: integer
          description: Page size for the current query
          default: 50
          example: 50
        firstPage:
          type: integer
          description: First page that can be reached, it is always 1
          example: 1
        lastPage:
          type: integer
          description: >-
            Represents the last page can be reached, also can be used as total
            pages for the current query
          example: 100
        totalRecords:
          type: integer
          description: Total records returned by the query
          example: 5000
    error:
      type: object
      title: Error
      properties:
        error:
          type: string
          description: Message describing what went wrong
          example: the requested resource could not be found
    validationError:
      type: object
      title: Validation Error
      description: >-
        Returned when one or more parameters do not pass the validation. Every
        key of the `error` object is the parameter that failed.
      properties:
        error:
          type: object
          additionalProperties:
            type: string
          example:
            page_size: must be a maximum of 100
