> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Leaderboard Around Entity

> Get the leaderboard around a specific entity.

Allowed entity token types: title, title_player_account, game_server

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| LeaderboardNotFound | 1567 |
| NoLeaderboardForStatistic | 1421 |
| SpecifiedVersionLeaderboardNotFound | 1583 |
| StatisticNotFound | 1195 |




## OpenAPI

````yaml /services/playfab/api-references/rest/progression/progression.openapi.json post /Leaderboard/GetLeaderboardAroundEntity
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Progression API
  description: Manage entity statistics Manage entity leaderboards
  termsOfService: https://playfab.com/terms/
  contact:
    url: https://community.playfab.com/index.html
  license:
    name: Apache 2.0
    url: https://github.com/PlayFab/API_Specs/blob/master/LICENSE
servers:
  - url: https://{titleId}.playfabapi.com
    description: PlayFab title endpoint
    variables:
      titleId:
        default: your_title_id
        description: Your PlayFab title ID (hex).
security: []
tags:
  - name: Leaderboards
    description: Leaderboards APIs
  - name: Statistics
    description: Statistics APIs
paths:
  /Leaderboard/GetLeaderboardAroundEntity:
    post:
      tags:
        - Leaderboards
      summary: Get Leaderboard Around Entity
      description: |
        Get the leaderboard around a specific entity.

        Allowed entity token types: title, title_player_account, game_server

        ## Error codes

        This operation may return the following PlayFab errors:

        | Error | Code |
        | --- | --- |
        | LeaderboardNotFound | 1567 |
        | NoLeaderboardForStatistic | 1421 |
        | SpecifiedVersionLeaderboardNotFound | 1583 |
        | StatisticNotFound | 1195 |
      operationId: GetLeaderboardAroundEntity
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetLeaderboardAroundEntityRequest'
        description: >-
          Request to load a section of a leaderboard centered on a specific
          entity.
      responses:
        '200':
          $ref: '#/components/responses/GetEntityLeaderboardResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  schemas:
    GetLeaderboardAroundEntityRequest:
      description: >-
        Request to load a section of a leaderboard centered on a specific
        entity.
      type: object
      properties:
        CustomTags:
          description: >-
            The optional custom tags associated with the request (e.g. build
            number, external trace identifiers, etc.).
          type: object
        Entity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: >-
            The optional entity to perform this action on. Defaults to the
            currently logged in entity.
        LeaderboardName:
          description: Name of the leaderboard.
          type: string
        MaxSurroundingEntries:
          description: >-
            Number of surrounding entries to return (in addition to specified
            entity). In general, the number of ranks above and below will be
            split into half. For example, if the specified value is 10, 5 ranks
            above and 5 ranks below will be retrieved. However, the numbers will
            get skewed in either direction when the specified entity is towards
            the top or bottom of the leaderboard. Also, the number of entries
            returned can be lower than the value specified for entries at the
            bottom of the leaderboard.
          type: number
          x-actualtype: uint32
        Version:
          description: Optional version of the leaderboard, defaults to current.
          type: number
          x-actualtype: uint32
      required:
        - LeaderboardName
        - MaxSurroundingEntries
      example:
        LeaderboardName: Points
        Version: 2
        Entity:
          Id: '819478109412'
          Type: title_player_account
          TypeString: title_player_account
    EntityKey:
      description: >-
        Combined entity type and ID structure which uniquely identifies a single
        entity.
      type: object
      properties:
        Id:
          description: Unique ID of the entity.
          type: string
        Type:
          description: >-
            Entity type. See
            https://learn.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types
          type: string
      required:
        - Id
    GetEntityLeaderboardResponse:
      description: Leaderboard response
      type: object
      properties:
        Columns:
          description: Leaderboard columns describing the sort directions.
          type: array
          items:
            $ref: '#/components/schemas/LeaderboardColumn'
          x-isclass: true
        EntryCount:
          description: The number of entries on the leaderboard.
          type: number
          x-actualtype: uint32
        NextReset:
          description: >-
            The time the next scheduled reset will occur. Null if the
            leaderboard does not reset on a schedule.
          type: string
        Rankings:
          description: >-
            Individual entity rankings in the leaderboard, in sorted order by
            rank.
          type: array
          items:
            $ref: '#/components/schemas/EntityLeaderboardEntry'
          x-isclass: true
        Version:
          description: Version of the leaderboard being returned.
          type: number
          x-actualtype: uint32
      required:
        - Version
        - EntryCount
      example:
        Version: 5
        Rankings:
          - Entity:
              Id: 1784371290HJA9
              Type: title_player_account
              TypeString: title_player_account
            DisplayName: FastHand
            Scores:
              - '4503'
            Rank: 1
          - Entity:
              Id: 1947109JA18412
              Type: title_player_account
              TypeString: title_player_account
            DisplayName: Mouse
            Scores:
              - '4502'
            Rank: 2
    ApiErrorWrapper:
      description: The basic wrapper around every failed API response
      type: object
      properties:
        code:
          description: Numerical HTTP code
          type: integer
        status:
          description: String HTTP code
          type: string
        error:
          description: Playfab error code
          type: string
        errorCode:
          description: Numerical PlayFab error code
          type: integer
        errorMessage:
          description: Description for the PlayFab errorCode
          type: string
        errorDetails:
          description: Detailed description of individual issues with the request object
          type: object
      required:
        - code
        - errorCode
    LeaderboardColumn:
      type: object
      properties:
        LinkedStatisticColumn:
          allOf:
            - $ref: '#/components/schemas/LinkedStatisticColumn'
          description: >-
            If the value for this column is sourced from a statistic, details of
            the linked column. Null if the leaderboard is not linked.
        Name:
          description: >-
            A name for the leaderboard column, unique per leaderboard
            definition.
          type: string
        SortDirection:
          allOf:
            - $ref: '#/components/schemas/LeaderboardSortDirection'
          description: The sort direction for this column.
      required:
        - Name
        - SortDirection
    EntityLeaderboardEntry:
      description: Individual rank of an entity in a leaderboard
      type: object
      properties:
        DisplayName:
          description: Entity's display name.
          type: string
        Entity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: Entity identifier.
        LastUpdated:
          description: >-
            The time at which the last update to the entry was recorded on the
            server.
          type: string
        Metadata:
          description: >-
            An opaque blob of data stored on the leaderboard entry. Note that
            the metadata is not used for ranking purposes.
          type: string
        Rank:
          description: Position on the leaderboard.
          type: number
          x-actualtype: int32
        Scores:
          description: Scores for the entry.
          type: array
          items:
            type: string
      required:
        - Rank
        - LastUpdated
    LinkedStatisticColumn:
      type: object
      properties:
        LinkedStatisticColumnName:
          description: >-
            The name of the statistic column that this leaderboard column is
            sourced from.
          type: string
        LinkedStatisticName:
          description: The name of the statistic.
          type: string
      required:
        - LinkedStatisticName
        - LinkedStatisticColumnName
    LeaderboardSortDirection:
      type: string
      enum:
        - Descending
        - Ascending
  responses:
    GetEntityLeaderboardResponse:
      description: Leaderboard response
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: >-
                  The Http status code. If X-ReportErrorAsSuccess header is set
                  to true, this will report the actual http error code.
              status:
                type: string
                description: The Http status code as a string.
              data:
                $ref: '#/components/schemas/GetEntityLeaderboardResponse'
            example:
              code: 200
              status: OK
              data:
                Version: 5
                Rankings:
                  - Entity:
                      Id: 1784371290HJA9
                      Type: title_player_account
                      TypeString: title_player_account
                    DisplayName: FastHand
                    Scores:
                      - '4503'
                    Rank: 1
                  - Entity:
                      Id: 1947109JA18412
                      Type: title_player_account
                      TypeString: title_player_account
                    DisplayName: Mouse
                    Scores:
                      - '4502'
                    Rank: 2
    ApiErrorWrapper:
      description: This is the outer wrapper for all responses with errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorWrapper'
  securitySchemes:
    EntityToken:
      type: apiKey
      in: header
      name: X-EntityToken
      description: >-
        This API requires an Entity Session Token, available from the Entity
        GetEntityToken method.

````

## Related topics

- [Get Leaderboard Around Entity](/services/playfab/api-references/rest/progression/leaderboards/get-leaderboard-around-entity.md)
- [PFLeaderboardsGetLeaderboardAroundEntityAsync](/services/playfab/api-references/c/pfleaderboards/functions/pfleaderboardsgetleaderboardaroundentityasync.md)
- [PFLeaderboardsGetLeaderboardAroundEntityGetResult](/services/playfab/api-references/c/pfleaderboards/functions/pfleaderboardsgetleaderboardaroundentitygetresult.md)
- [PFLeaderboardsGetLeaderboardAroundEntityRequest](/services/playfab/api-references/c/pfleaderboardstypes/structs/pfleaderboardsgetleaderboardaroundentityrequest.md)
- [PFLeaderboardsGetLeaderboardAroundEntityGetResultSize](/services/playfab/api-references/c/pfleaderboards/functions/pfleaderboardsgetleaderboardaroundentitygetresultsize.md)
