openapi: 3.0.2
info:
    title: TonAPI embed (TESTNET)
    version: 1.0.0
    description: Provide access to indexed TON blockchain data related to the transfers of funds (TON and Jettons).
    contact:
        name: Support
        email: support@tonkeeper.com
servers:
    - url: "https://demo-embed.tonapi.io"
paths:
    /resolve/{domain}:
        get:
            description: Method for resolving domain names on the TON blockchain (presented as NFT), such as wallet.ton. Does not work for any domain name, but for a name that has a corresponding DNS record. Returns the address of the contract specified in the DNS record.
            operationId: resolve
            tags:
                - Blockchain
            parameters:
                - name: domain
                  in: path
                  description: Domain to resolve
                  required: true
                  schema:
                      type: string
                      example: "wallet.ton"
            responses:
                '200':
                    description: Resolved address
                    content:
                        application/json:
                            schema:
                                type: object
                                required:
                                    - account_id
                                properties:
                                    account_id:
                                        type: string
                                        description: Resolved address
                                        example: "0:b9fa6045aee35c428b4f7fa9f0e6dfd2e51253a6e7c661b76d6803796ebf80c5"
                'default':
                    $ref: '#/components/responses/Error'
    /account/{address}:
        post:
            description: Method to add a new Deposit address for tracking. Since a Jetton Wallet in the TON blockchain is a separate smart contract, when adding a Jetton Deposit smart contract to tracking, the owner of this wallet (also a smart contract) is added to the tracking as a TON Deposit smart contract.
            operationId: addAccount
            tags:
                - Blockchain
            parameters:
                - name: address
                  in: path
                  description: Address to add
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
            responses:
                '200':
                    description: Account added
                'default':
                    $ref: '#/components/responses/Error'
        get:
            description: Method for obtaining the TON balance associated with Deposit address for the last Masterchain block known to the service.
            operationId: getTonBalance
            tags:
                - Blockchain
            parameters:
                - name: address
                  in: path
                  description: Deposit address to get balance for
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
            responses:
                '200':
                    description: Balance for Deposit address
                    content:
                        application/json:
                            schema:
                                type: object
                                required:
                                    - balance
                                    - last_lt
                                    - last_block_seqno
                                    - last_processed_tx_lt
                                properties:
                                    balance:
                                        type: string
                                        description: Balance associated with Deposit address in Minimum indivisible units of measurement
                                        example: "1000000000"
                                    last_lt:
                                        type: integer
                                        format: int64
                                        description: Last transaction lt, identifies the last known Transaction on the Deposit smart contract
                                        example: 45537112000001
                                    last_block_seqno:
                                        type: integer
                                        description: Last Masterchain block number which proofed current account state
                                        example: 263000000
                                    last_processed_tx_lt:
                                        type: integer
                                        description: Last processed transaction which is included in the Transfer history. Can be smaller than last_lt because indexer processes transactions with some latency for ordering.
                                        format: int64
                                        example: 1630000000
                'default':
                    $ref: '#/components/responses/Error'
    /account/{address}/history:
        get:
            description: Method for obtaining the TON Transfer history (with pagination) for a specific Deposit address.
            operationId: getTonTransfers
            tags:
                - Blockchain
            parameters:
                - name: address
                  in: path
                  description: Deposit address
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                - name: after_lt
                  in: query
                  description: Get transfers after this lt (not included)
                  schema:
                      type: integer
                      example: 0
                - name: limit
                  in: query
                  description: Limit number of returning records
                  schema:
                      default: 100
                      type: integer
            responses:
                '200':
                    description: Transfers for address
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/TonTransfers'
                'default':
                    $ref: '#/components/responses/Error'
    /account/{address}/history/{hash}:
        get:
            description: Method for obtaining a specific TON Transfer by hash.
            operationId: getTonTransfer
            tags:
                - Blockchain
            parameters:
                - name: address
                  in: path
                  description: Deposit address to get transfer for
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                - name: hash
                  in: path
                  description: Hash of transfer
                  required: true
                  schema:
                      type: string
                      example: "9de44522107601d2c1c6f3c532b559380f371d30b7744c5ea84af0128df0d07c"
            responses:
                '200':
                    description: Transfer
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/TonTransfer'
                'default':
                    $ref: '#/components/responses/Error'
    /jetton/{jetton}/{address}:
        post:
            description: Method to add a new Deposit address for tracking jetton transfers.
            operationId: addJettonAccount
            tags:
                - Blockchain
            parameters:
                - name: jetton
                  in: path
                  description: Currency (jetton master contract address)
                  required: true
                  schema:
                      type: string
                      example: "0:41c572ce41529ae0e736ff7890188b151040cb84a8209e1f12013ebf5f15f0ca"
                - name: address
                  in: path
                  description: The Deposit address (owner of the jetton wallet)
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
            responses:
                '200':
                    description: Wallet added
                'default':
                    $ref: '#/components/responses/Error'
        get:
            description: Method for obtaining the jetton balance associated with Deposit address for the last Masterchain block known to the service.
            operationId: getJettonBalance
            tags:
                - Blockchain
            parameters:
                - name: jetton
                  in: path
                  description: Currency to get balance for (Jetton master contract address)
                  required: true
                  schema:
                      type: string
                      example: "0:41c572ce41529ae0e736ff7890188b151040cb84a8209e1f12013ebf5f15f0ca"
                - name: address
                  in: path
                  description: Deposit address to get balance for
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
            responses:
                '200':
                    description: Balance for Deposit address
                    content:
                        application/json:
                            schema:
                                type: object
                                required:
                                    - balance
                                    - last_lt
                                    - last_block_seqno
                                    - last_processed_tx_lt
                                properties:
                                    balance:
                                        type: string
                                        description: Balance associated with Deposit address in Minimum indivisible units of measurement
                                        example: "500000000000"
                                    last_lt:
                                        type: integer
                                        format: int64
                                        description: Last transaction lt, identifies the last known Transaction on the Deposit smart contract
                                        example: 24748213000001
                                    last_block_seqno:
                                        type: integer
                                        description: Last Masterchain block number which proofed current account state
                                        example: 22026369
                                    last_processed_tx_lt:
                                        type: integer
                                        description: Last processed transaction which is included in the Transfer history. Can be smaller than last_lt because indexer processes transactions with some latency for ordering.
                                        format: int64
                                        example: 24748213000001
                'default':
                    $ref: '#/components/responses/Error'
    /jetton/{jetton}/{address}/history:
        get:
            description: Method for obtaining the jetton Transfer history (with pagination) for a specific Deposit address.
            operationId: getJettonTransfers
            tags:
                - Blockchain
            parameters:
                - name: address
                  in: path
                  description: Deposit address
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                - name: jetton
                  in: path
                  description: Currency (jetton master contract address)
                  required: true
                  schema:
                      type: string
                      example: "0:41c572ce41529ae0e736ff7890188b151040cb84a8209e1f12013ebf5f15f0ca"
                - name: after_lt
                  in: query
                  description: Get transfers after this lt (not included)
                  schema:
                      type: integer
                      example: 0
                - name: limit
                  in: query
                  description: Limit number of returning records
                  schema:
                      default: 100
                      type: integer
            responses:
                '200':
                    description: Transfers for address
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/JettonTransfers'
                'default':
                    $ref: '#/components/responses/Error'
    /jetton/{jetton}/{address}/history/{hash}:
        get:
            description: Method for obtaining a specific jetton Transfer by hash.
            operationId: getJettonTransfer
            tags:
                - Blockchain
            parameters:
                - name: jetton
                  in: path
                  description: Currency (jetton master contract address)
                  required: true
                  schema:
                      type: string
                      example: "0:41c572ce41529ae0e736ff7890188b151040cb84a8209e1f12013ebf5f15f0ca"
                - name: address
                  in: path
                  description: Deposit address to get transfer for
                  required: true
                  schema:
                      type: string
                      example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                - name: hash
                  in: path
                  description: Hash of transfer
                  required: true
                  schema:
                      type: string
                      example: "f9307911eef3782ceb9b0904f2aa04214abd6f8428260b5158b8d2dad2a5d7c3"
            responses:
                '200':
                    description: Transfer
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/JettonTransfer'
                'default':
                    $ref: '#/components/responses/Error'
components:
    schemas:
        JettonTransfer:
            type: object
            required:
                - source_jetton_wallet
                - destination_jetton_wallet
                - jetton
                - amount
                - timestamp
                - attached_tons
                - comment
                - lt
                - hash
                - fee
                - fee_finalized
            properties:
                source:
                    type: string
                    description: Source address of transfer
                    example: "0:c4fb97b38b09744071de474d77ce4a031b7a278f94e81c304dff1a1ea30d4d71"
                destination:
                    type: string
                    description: Destination address of transfer
                    example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                source_jetton_wallet:
                    type: string
                    description: Source jetton wallet address
                    example: "0:a529f8e2639f6f9ce37e477825d1fcb40d8fc455ecb8a90aeb295a9b1eecf99e"
                destination_jetton_wallet:
                    type: string
                    description: Destination jetton wallet address
                    example: "0:cf6e2c796e30377448002c064352c136078cabe4c2755d59c1581190c4078793"
                jetton:
                    type: string
                    description: Jetton (Jetton master smart contract address)
                    example: "0:41c572ce41529ae0e736ff7890188b151040cb84a8209e1f12013ebf5f15f0ca"
                amount:
                    type: string
                    description: Amount of jetton
                    example: "500000000000"
                attached_tons:
                    type: string
                    description: Amount of TON attached to jetton
                    example: "1"
                timestamp:
                    type: integer
                    description: Timestamp of transfer
                    example: 1723588674
                lt:
                    type: integer
                    description: Transaction lt
                    example: 24748213000001
                hash:
                    type: string
                    description: Transaction hash
                    example: "f9307911eef3782ceb9b0904f2aa04214abd6f8428260b5158b8d2dad2a5d7c3"
                comment:
                    type: string
                    description: Comment for transfer
                    example: "123456"
                fee:
                    type: string
                    description: Total fee (only for withdraws, deposits are for free)
                    example: "100500"
                fee_finalized:
                    type: boolean
                    description: Fee value is final or has timed out
        JettonTransfers:
            type: object
            required:
                - transfers
                - last_lt
            properties:
                transfers:
                    type: array
                    items:
                        $ref: '#/components/schemas/JettonTransfer'
                last_lt:
                    type: integer
                    description: Last transaction lt (you can use it to put into request for next page)
                    format: int64
                    example: 45537112000001
        TonTransfer:
            type: object
            required:
                - timestamp
                - lt
                - hash
                - source
                - fee
            properties:
                timestamp:
                    type: integer
                    format: int64
                    description: Timestamp of transfer
                    example: 1723588650
                fee:
                    type: string
                    description: Fee of transaction
                    example: "1000000000"
                source:
                    type: string
                    description: Source address of message
                    example: "0:c4fb97b38b09744071de474d77ce4a031b7a278f94e81c304dff1a1ea30d4d71"
                lt:
                    type: integer
                    format: int64
                    description: Transaction lt
                    example: 24748203000001
                hash:
                    type: string
                    description: Transaction hash
                    example: "9de44522107601d2c1c6f3c532b559380f371d30b7744c5ea84af0128df0d07c"
                destinations:
                    type: array
                    items:
                        type: object
                        required:
                            - destination
                            - amount
                            - comment
                        properties:
                            destination:
                                type: string
                                description: Destination address of message
                                example: "0:144d38485e455fe78be6bfc416a42b19d042acd73676de051415fd169424341b"
                            amount:
                                type: string
                                description: Amount of TON
                                example: "2000000000"
                            comment:
                                type: string
                                description: Comment for transfer
                                example: "123456"
        TonTransfers:
            type: object
            required:
                - transfers
                - last_lt
            properties:
                transfers:
                    type: array
                    items:
                        $ref: '#/components/schemas/TonTransfer'
                last_lt:
                    type: integer
                    format: int64
                    description: Last transaction lt (you can use it to put into request for next page)
                    example: 45537112000001
        Error:
            type: object
            properties:
                code:
                    type: integer
                    format: int32
                message:
                    type: string
                    example: "Unexpected error"
    responses:
        Error:
            description: Unexpected error
            content:
                application/json:
                    schema:
                        $ref: '#/components/schemas/Error'
