> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getTokenAccountsByOwner

> getTokenAccountsByOwner trả về mọi tài khoản SPL Token thuộc sở hữu của một ví Solana, được lọc theo mint hoặc chương trình token, đồng thời hỗ trợ đồng bộ gia tăng bằng changedSinceSlot.

<Info>
  **Tính năng mới**: `getTokenAccountsByOwner` hiện hỗ trợ tham số `changedSinceSlot` để cập nhật gia tăng. Khi được chỉ định, phương thức chỉ trả về các tài khoản token đã được sửa đổi tại hoặc sau số slot đã cho. Tính năng này rất phù hợp để theo dõi thay đổi số dư token và cập nhật danh mục đầu tư.
</Info>

## Tham số yêu cầu

<ParamField body="address" type="string" required>
  Địa chỉ ví Solana (khóa công khai) của chủ sở hữu tài khoản cần truy vấn lượng token nắm giữ, dưới dạng chuỗi được mã hóa base-58.
</ParamField>

<ParamField body="mint" type="string">
  Địa chỉ mint token Solana cụ thể để chỉ truy xuất các tài khoản của một token hoặc NFT nhất định.
</ParamField>

<ParamField body="programId" type="string">
  ID chương trình token Solana cụ thể (thường là chương trình SPL Token) đã tạo các tài khoản token.
</ParamField>

<ParamField body="commitment" type="string">
  Mức commitment cho yêu cầu.

  * `confirmed`
  * `finalized`
  * `processed`
</ParamField>

<ParamField body="minContextSlot" type="number">
  Slot tối thiểu mà tại đó yêu cầu có thể được đánh giá.
</ParamField>

<ParamField body="dataSlice" type="object">
  Yêu cầu một phần dữ liệu của tài khoản.
</ParamField>

<ParamField body="dataSlice.length" type="number">
  Số byte cần trả về.
</ParamField>

<ParamField body="dataSlice.offset" type="number">
  Độ lệch byte để bắt đầu đọc.
</ParamField>

<ParamField body="encoding" type="string">
  Định dạng mã hóa cho dữ liệu tài khoản.

  * `base58`
  * `base64`
  * `base64+zstd`
  * `jsonParsed`
</ParamField>

<ParamField body="changedSinceSlot" type="number">
  Chỉ trả về các tài khoản đã được sửa đổi tại hoặc sau số slot này. Hữu ích cho các bản cập nhật gia tăng.
</ParamField>


## OpenAPI

````yaml vi/openapi/rpc-http/getTokenAccountsByOwner.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: >-
    API khám phá tài khoản token Solana toàn diện để truy xuất số dư token SPL,
    NFT và các tài sản token khác liên kết với bất kỳ địa chỉ ví nào trên
    blockchain Solana.
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://mainnet.helius-rpc.com
    description: Điểm cuối RPC Mainnet
  - url: https://devnet.helius-rpc.com
    description: Điểm cuối RPC Devnet
security: []
paths:
  /:
    post:
      tags:
        - RPC
      summary: getTokenAccountsByOwner
      description: >
        Truy xuất tất cả tài khoản token SPL thuộc sở hữu của một địa chỉ ví
        Solana cụ thể với các tùy chọn lọc mạnh mẽ.

        API thiết yếu này cho phép nhà phát triển khám phá toàn bộ tài sản
        token, bao gồm token có thể thay thế và NFT,

        với khả năng lọc theo địa chỉ mint token cụ thể hoặc giới hạn ở các tài
        khoản do những chương trình token nhất định tạo ra.

        Hỗ trợ dữ liệu đã phân tích để cung cấp thông tin token dễ đọc, bao gồm
        số dư, số chữ số thập phân và trạng thái sở hữu.

        Đóng vai trò quan trọng đối với ví, trình theo dõi danh mục đầu tư và
        ứng dụng DeFi cần dữ liệu toàn diện về tài sản token.
      operationId: getTokenAccountsByOwner
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  enum:
                    - '2.0'
                  description: Phiên bản giao thức JSON-RPC.
                  example: '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: Mã định danh duy nhất cho yêu cầu.
                  example: '1'
                  default: '1'
                method:
                  type: string
                  enum:
                    - getTokenAccountsByOwner
                  description: Tên của phương thức RPC cần gọi.
                  example: getTokenAccountsByOwner
                  default: getTokenAccountsByOwner
                params:
                  type: array
                  description: >-
                    Các tham số để truy vấn tài khoản token thuộc sở hữu của một
                    khóa công khai cụ thể.
                  default:
                    - A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                    - programId: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                    - encoding: jsonParsed
                  items:
                    oneOf:
                      - type: string
                        description: >-
                          Địa chỉ ví Solana (pubkey) của chủ sở hữu tài khoản
                          cần truy vấn tài sản token, dưới dạng chuỗi được mã
                          hóa base-58.
                        example: A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                      - type: object
                        description: >-
                          Cấu hình bộ lọc để thu hẹp tài khoản token theo địa
                          chỉ mint hoặc ID chương trình.
                        properties:
                          mint:
                            type: string
                            description: >-
                              Địa chỉ mint token Solana cụ thể để chỉ truy xuất
                              các tài khoản của một token hoặc NFT nhất định.
                            example: 2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR
                          programId:
                            type: string
                            description: >-
                              ID chương trình token Solana cụ thể (thường là
                              chương trình SPL Token) đã tạo các tài khoản
                              token.
                            example: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                      - type: object
                        description: Đối tượng cấu hình có các trường tùy chọn.
                        properties:
                          commitment:
                            type: string
                            description: Mức cam kết cho yêu cầu.
                            enum:
                              - confirmed
                              - finalized
                              - processed
                            example: finalized
                          minContextSlot:
                            type: integer
                            description: >-
                              Slot tối thiểu mà tại đó yêu cầu có thể được đánh
                              giá.
                            example: 1000
                          dataSlice:
                            type: object
                            description: Yêu cầu một phần dữ liệu của tài khoản.
                            properties:
                              length:
                                type: integer
                                description: Số byte cần trả về.
                                example: 10
                              offset:
                                type: integer
                                description: Độ lệch byte để bắt đầu đọc.
                                example: 0
                          encoding:
                            type: string
                            description: Định dạng mã hóa cho dữ liệu tài khoản.
                            enum:
                              - base58
                              - base64
                              - base64+zstd
                              - jsonParsed
                            example: jsonParsed
                          changedSinceSlot:
                            type: integer
                            description: >-
                              Chỉ trả về các tài khoản đã được sửa đổi tại hoặc
                              sau số slot này. Hữu ích cho các bản cập nhật gia
                              tăng.
                            example: 464175999
      responses:
        '200':
          description: Đã truy xuất thành công các tài khoản token theo chủ sở hữu.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: Phiên bản giao thức JSON-RPC.
                    enum:
                      - '2.0'
                    example: '2.0'
                  id:
                    type: string
                    description: Mã định danh khớp với yêu cầu.
                    example: '1'
                  result:
                    type: object
                    description: Ngữ cảnh và thông tin chi tiết về tài khoản.
                    properties:
                      context:
                        type: object
                        description: Ngữ cảnh của phản hồi.
                        properties:
                          apiVersion:
                            type: string
                            description: Phiên bản API.
                            example: 2.0.15
                          slot:
                            type: integer
                            description: Slot mà dữ liệu được truy xuất.
                            example: 341197933
                      value:
                        type: array
                        description: Danh sách tài khoản token.
                        items:
                          type: object
                          properties:
                            pubkey:
                              type: string
                              description: >-
                                Pubkey của tài khoản dưới dạng chuỗi được mã hóa
                                base-58.
                              example: BGocb4GEpbTFm8UFV2VsDSaBXHELPfAXrvd4vtt8QWrA
                            account:
                              type: object
                              description: Thông tin chi tiết về tài khoản token.
                              properties:
                                lamports:
                                  type: integer
                                  description: Số lamport được gán cho tài khoản.
                                  example: 2039280
                                owner:
                                  type: string
                                  description: >-
                                    Pubkey của chương trình được gán cho tài
                                    khoản này.
                                  example: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                                data:
                                  type: object
                                  description: >-
                                    Dữ liệu trạng thái token liên kết với tài
                                    khoản.
                                  properties:
                                    program:
                                      type: string
                                      description: Tên chương trình.
                                      example: spl-token
                                    parsed:
                                      type: object
                                      description: Dữ liệu token đã phân tích.
                                      properties:
                                        info:
                                          type: object
                                          description: Thông tin tài khoản token.
                                          properties:
                                            isNative:
                                              type: boolean
                                              description: >-
                                                Cho biết tài khoản có nắm giữ SOL gốc
                                                hay không.
                                              example: false
                                            mint:
                                              type: string
                                              description: Pubkey của mint token.
                                              example: >-
                                                2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR
                                            owner:
                                              type: string
                                              description: Pubkey của chủ sở hữu tài khoản.
                                              example: >-
                                                A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                                            state:
                                              type: string
                                              description: Trạng thái tài khoản token.
                                              example: initialized
                                            tokenAmount:
                                              type: object
                                              description: Thông tin chi tiết về lượng token.
                                              properties:
                                                amount:
                                                  type: string
                                                  description: Số dư thô chưa áp dụng chữ số thập phân.
                                                  example: '420000000000000'
                                                decimals:
                                                  type: integer
                                                  description: Số chữ số thập phân.
                                                  example: 6
                                                uiAmount:
                                                  type: number
                                                  description: >-
                                                    Số dư ở định dạng thân thiện với người
                                                    dùng.
                                                  example: 420000000
                                                uiAmountString:
                                                  type: string
                                                  description: Số dư dưới dạng chuỗi.
                                                  example: '420000000'
                                    space:
                                      type: integer
                                      description: Không gian được phân bổ cho tài khoản.
                                      example: 165
                                executable:
                                  type: boolean
                                  description: >-
                                    Cho biết tài khoản có chứa chương trình hay
                                    không.
                                  example: false
                                rentEpoch:
                                  type: integer
                                  description: >-
                                    Epoch mà tại đó tài khoản sẽ phải trả phí
                                    thuê tiếp theo.
                                  example: 18446744073709552000
                                space:
                                  type: integer
                                  description: Kích thước dữ liệu của tài khoản.
                                  example: 165
              example:
                jsonrpc: '2.0'
                id: '1'
                result:
                  context:
                    apiVersion: 2.0.15
                    slot: 341197933
                  value:
                    - pubkey: BGocb4GEpbTFm8UFV2VsDSaBXHELPfAXrvd4vtt8QWrA
                      account:
                        lamports: 2039280
                        owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
                        data:
                          program: spl-token
                          parsed:
                            info:
                              isNative: false
                              mint: 2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR
                              owner: A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd
                              state: initialized
                              tokenAmount:
                                amount: '420000000000000'
                                decimals: 6
                                uiAmount: 420000000
                                uiAmountString: '420000000'
                          space: 165
                        executable: false
                        rentEpoch: 18446744073709552000
                        space: 165
        '400':
          description: >-
            Yêu cầu không hợp lệ - Tham số yêu cầu không hợp lệ hoặc yêu cầu
            không đúng định dạng.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: Invalid params
                id: '1'
        '401':
          description: Không được phép - Khóa API không hợp lệ hoặc bị thiếu.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: Unauthorized
                id: '1'
        '429':
          description: Quá nhiều yêu cầu - Đã vượt quá giới hạn tốc độ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: Too many requests
                id: '1'
        '500':
          description: Lỗi máy chủ nội bộ - Đã xảy ra lỗi trên máy chủ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: Internal error
                id: '1'
        '503':
          description: Dịch vụ không khả dụng - Dịch vụ tạm thời không khả dụng.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: Service unavailable
                id: '1'
        '504':
          description: Hết thời gian chờ cổng - Yêu cầu đã hết thời gian chờ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: Gateway timeout
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: Phiên bản giao thức JSON-RPC.
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: Mã lỗi.
              example: -32602
            message:
              type: string
              description: Thông báo lỗi.
            data:
              type: object
              description: Dữ liệu bổ sung về lỗi.
        id:
          type: string
          description: Mã định danh khớp với yêu cầu.
          example: '1'
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: >-
        Khóa API Helius của bạn. Bạn có thể nhận khóa miễn phí trong [bảng điều
        khiển](https://dashboard.helius.dev/api-keys).

````