Module @tzkt/sdk-api

TzKT API SDK

Auto-generated from OpenApi spec using @tzkt/oazapfts.
Supports most of the TzKT features including deep filtering and deep sorting.

Install

npm i @tzkt/sdk-api

Use

Simplest request

Simplest example of getting double baking operations, accused of being such by a certain address.

import { operationsGetDoubleBaking } from '@tzkt/sdk-api'

await operationsGetDoubleBaking(
{
quote: 'Btc',
accuser: {
in: ['tz3VEZ4k6a4Wx42iyev6i2aVAptTRLEAivNN']
}
}
)

Overriding base API URL

You may override base URL used by the package in the following manner. This may come useful should you want to make requests to a test network or to your custom server.

import * as api from "@tzkt/sdk-api";

api.defaults.baseUrl = "https://api.ithacanet.tzkt.io/";

In case you need to override request headers, this is also possible.

import * as api from "@tzkt/sdk-api";

api.defaults.headers = {
access_token: "secret",
};

Please refer to the original documentation for more details on how to configure defaults.

More involved examples

Access BigMaps

Please refer to an article on BigMaps indexing for a more detailed explanation on what these requests allow you to achieve.

Accessing BigMap by Ptr

import { bigMapsGetBigMapById } from '@tzkt/sdk-api'

const bigMapPtr = 543

await bigMapsGetBigMapById(bigMapPtr)

Accessing BigMap by the path in the contract storage

import { contractsGetBigMapByName } from '@tzkt/sdk-api'

const contractAddress = 'KT1TtaMcoSx5cZrvaVBWsFoeZ1L15cxo5AEy'
const pathToBigMap = 'ledger'

await contractsGetBigMapByName(
contractAddress,
pathToBigMap
)

Accessing BigMap keys

import { bigMapsGetKeys } from '@tzkt/sdk-api'

const bigMapId = 511
const limit = 10

await bigMapsGetKeys(
bigMapId,
{ limit }
)

Accessing All owners of NFT with non-zero balance

import { bigMapsGetKeys } from '@tzkt/sdk-api'

const bigMapId = 511
const key = {
value: 154,
path: 'nat'
}
const minValue = 0

await bigMapsGetKeys(
bigMapId,
{
key: {
eq: {
jsonValue: `${key.value}`,
jsonPath: key.path
}
},
value: {
gt: {
jsonValue: `${minValue}`
}
}
}
)

Accessing all updates of all BigMaps of a specific contract

import { bigMapsGetBigMapUpdates } from '@tzkt/sdk-api'

const contract = 'KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV'
await bigMapsGetBigMapUpdates({
contract: {
eq: contract
}
})

Accessing Tokens API

Please refer to an article on Tokens indexing for a more detailed explanation on what these requests allow you to achieve.

Accessing tokens transfers with deep fields selection

import { tokensGetTokenTransfers } from '@tzkt/sdk-api'

const tokenId = 778919
const limit = 2
const sort = 'id'
const fields = [
'from.address',
'to.address',
'amount',
'token.metadata.symbol',
'token.metadata.decimals'
]

await tokensGetTokenTransfers({
tokenId: {
eq: tokenId
},
sort: {
desc: sort
},
limit,
select: {
fields
}
})

Accessing FA1.2 tokens with the largest number of holders

import { tokensGetTokens } from '@tzkt/sdk-api'

const standard = 'fa1.2'
const sort = 'holdersCount'
const limit = 10

const r = await tokensGetTokens({
standard: {
eq: standard
},
sort: {
desc: sort
},
limit
})

Accessing all account's NFTs

import { tokensGetTokenBalances } from '@tzkt/sdk-api'

const account = 'tz1SLgrDBpFWjGCnCwyNpCpQC1v8v2N8M2Ks'
const minBalance = 0
const symbol = 'OBJKT'
const limit = 10

const r = await tokensGetTokenBalances({
account: {
eq: account
},
balance: {
ne: `${minBalance}`
},
tokenMetadata: {
eq: {
jsonPath: 'symbol',
jsonValue: symbol
}
},
limit
})

Accessing whale transfers of a token

import { tokensGetTokenTransfers } from '@tzkt/sdk-api'

const tokenId = 85
const minAmount = '100000000000000000000000'
const sort = 'id'
const limit = 10

const r = await tokensGetTokenTransfers({
tokenId: {
eq: tokenId
},
amount: {
gt: minAmount
},
sort: {
desc: sort
},
limit
})

Accessing "mints" of a token

import { tokensGetTokenTransfers } from '@tzkt/sdk-api'

const tokenId = 85
const sort = 'id'
const limit = 10

const r = await tokensGetTokenTransfers({
tokenId: {
eq: tokenId
},
from: {
null: true
},
sort: {
desc: sort
},
limit
})

Accessing Transactions

Please refer to an article on Transactions querying for a more detailed explanation on what these requests allow you to achieve.

Accessing incoming transfers for the account

import { operationsGetTransactions } from '@tzkt/sdk-api'

const target = 'KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV'
const parameter = {
path: 'to',
value: 'tz1aKTCbAUuea2RV9kxqRVRg3HT7f1RKnp6a'
}

const r = await operationsGetTransactions({
target: {
eq: target
},
parameter: {
eq: {
jsonPath: parameter.path,
jsonValue: parameter.value
}
}
})

Accessing Dexter XTZ to USDtz trades with specified amount

import { operationsGetTransactions } from '@tzkt/sdk-api'

const target = 'KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV'
const parameter = {
path: 'to',
value: 'tz1aKTCbAUuea2RV9kxqRVRg3HT7f1RKnp6a'
}

const r = await operationsGetTransactions({
target: {
eq: target
},
parameter: {
eq: {
jsonPath: parameter.path,
jsonValue: parameter.value
}
}
})

Accessing Atomex atomic swaps with specified refund time

import { operationsGetTransactions } from '@tzkt/sdk-api'

const target = 'KT1VG2WtYdSWz5E7chTeAdDPZNy2MpP8pTfL'
const filterField = 'settings.refund_time'
const timeFrame = '2021-02-*'

const r = await operationsGetTransactions({
target: {
eq: target
},
parameter: {
as: {
jsonPath: filterField,
jsonValue: timeFrame
}
}
})

Accessing Dexter wXTZ/XTZ trades

import { operationsGetTransactions } from '@tzkt/sdk-api'

const target = 'KT1D56HQfMmwdopmFLTwNHFJSs6Dsg2didFo'
const entrypoints = ['xtzToToken', 'tokenToXtz', 'tokenToToken']

const r = await operationsGetTransactions({
target: {
eq: target
},
entrypoint: {
in: entrypoints
}
})

Accessing operations with tzBTC related to a specific account

import { operationsGetTransactions } from '@tzkt/sdk-api'

const target = 'KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn'
const entrypoints = ['mint', 'transfer', 'burn']
const parameter = '*tz1aKTCbAUuea2RV9kxqRVRg3HT7f1RKnp6a*'

const r = await operationsGetTransactions({
target: {
eq: target
},
entrypoint: {
in: entrypoints
},
parameter: {
as: {
jsonValue: parameter
}
}
})

With node.js or a custom fetch library

Please refer to the documentation of the original codegen library.

Update & publish

This package is managed by Lerna. All publishing and dep management should be done using it. Only regeneration of APIs is kept local (for now).

Inside this package

  • Get the latest swagger file
  • Use it to re-generate APIs
  • Fix linting and prettify
npm run sync-swagger
npm run generate
npm run fix

Building and publishing

You may build this package for local testing with simple npm run build. For publishing and deploying to production all builds should be done via Lerna.

After you've committed your changes and ready to publish, please follow Build and publish instructions in the root of this repository.

Index

Type Aliases

Account AccountParameter AccountTypeParameter ActivationOperation AddressNullParameter AddressParameter Alias AnnotationType BakerRewards BakingOperation BakingRight BakingRightStatusParameter BakingRightTypeParameter BallotOperation BigMap BigMapActionParameter BigMapDiff BigMapInterface BigMapKey BigMapKeyHistorical BigMapKeyShort BigMapKeyUpdate BigMapTagsParameter BigMapUpdate Block BoolParameter Commitment Constant Contract ContractEvent ContractInterface ContractKindParameter ContractTagsParameter ContractView CreatorInfo Cycle DateTimeParameter Delegate DelegateInfo DelegationOperation Delegator DelegatorRewards Domain DoubleBakingOperation DoubleEndorsingOperation DoublePreendorsingOperation DrainDelegateOperation EndorsementOperation EndorsingRewardOperation Entrypoint EntrypointInterface EventInterface ExpressionParameter HistoricalBalance IAnnotation IMicheline IncreasePaidStorageOperation Int32NullParameter Int32Parameter Int64NullParameter Int64Parameter JsonParameter ManagerInfo MichelineFormat MichelinePrim MichelineType MigrationKindParameter MigrationOperation NatParameter NonceRevelationOperation OffsetParameter Operation OperationError OperationStatusParameter OriginatedContract OriginationOperation PeriodInfo PreendorsementOperation PrimType Proposal ProposalAlias ProposalOperation Protocol ProtocolConstants ProtocolParameter Quote QuoteShort RawJson RegisterConstantOperation RelatedContract RevealOperation RevelationPenaltyOperation RewardSplit SelectParameter SelectionParameter SetDepositsLimitOperation Software SoftwareAlias SortMode SortParameter SourceOperation SplitDelegator State Statistics StorageRecord StringParameter Symbols TimestampParameter Token TokenBalance TokenBalanceShort TokenInfo TokenStandardParameter TokenTransfer TransactionOperation TransferTicketOperation TxParameter TxRollupCommitOperation TxRollupDispatchTicketsOperation TxRollupFinalizeCommitmentOperation TxRollupOriginationOperation TxRollupRejectionOperation TxRollupRemoveCommitmentOperation TxRollupReturnBondOperation TxRollupSubmitBatchOperation UpdateConsensusKeyOperation VdfRevelationOperation VoteParameter VoterSnapshot VoterStatusParameter VotingEpoch VotingPeriod

Variables

Functions

accountsGet accountsGetBalance accountsGetBalanceAtDate accountsGetBalanceAtLevel accountsGetBalanceHistory accountsGetBalanceReport accountsGetByAddress accountsGetContracts accountsGetCount accountsGetCounter accountsGetDelegators accountsGetOperations bigMapsGetBigMapById bigMapsGetBigMapType bigMapsGetBigMapUpdates bigMapsGetBigMaps bigMapsGetBigMapsCount bigMapsGetHistoricalKeys bigMapsGetKey bigMapsGetKey2 bigMapsGetKeyUpdates bigMapsGetKeys blocksGet blocksGetByDate blocksGetByDate2 blocksGetByHash blocksGetByLevel blocksGetByLevel2 blocksGetCount commitmentsGet commitmentsGetAll commitmentsGetCount constantsGet constantsGetByAddress constantsGetCount contractsBuildEntrypointParametersGet contractsBuildEntrypointParametersPost contractsGet contractsGetBigMapByName contractsGetBigMapByNameKeys contractsGetBigMaps contractsGetByAddress contractsGetCode contractsGetContractViewByName contractsGetContractViews contractsGetCount contractsGetEntrypointByName contractsGetEntrypoints contractsGetHistoricalKeys contractsGetInterface contractsGetKey contractsGetKey2 contractsGetKeyUpdates contractsGetRawStorage contractsGetRawStorageHistory contractsGetRawStorageSchema contractsGetSame contractsGetSimilar contractsGetStorage contractsGetStorageHistory contractsGetStorageSchema cyclesGet cyclesGetByIndex cyclesGetCount delegatesGet delegatesGetByAddress delegatesGetCount domainsGet domainsGetByName domainsGetCount eventsGetContractEvents eventsGetContractEventsCount headGet helpersPostInject helpersPostRunScriptView operationsGetActivationByHash operationsGetActivations operationsGetActivationsCount operationsGetBaking operationsGetBakingById operationsGetBakingCount operationsGetBallotByHash operationsGetBallots operationsGetBallotsCount operationsGetByHash operationsGetByHashCounter operationsGetByHashCounterNonce operationsGetDelegationByHash operationsGetDelegationStatus operationsGetDelegations operationsGetDelegationsCount operationsGetDoubleBaking operationsGetDoubleBakingByHash operationsGetDoubleBakingCount operationsGetDoubleEndorsing operationsGetDoubleEndorsingByHash operationsGetDoubleEndorsingCount operationsGetDoublePreendorsing operationsGetDoublePreendorsingByHash operationsGetDoublePreendorsingCount operationsGetDrainDelegateByHash operationsGetDrainDelegateOps operationsGetDrainDelegateOpsCount operationsGetEndorsementByHash operationsGetEndorsements operationsGetEndorsementsCount operationsGetEndorsingRewardById operationsGetEndorsingRewards operationsGetEndorsingRewardsCount operationsGetIncreasePaidStorageByHash operationsGetIncreasePaidStorageCount operationsGetIncreasePaidStorageOps operationsGetMigrationById operationsGetMigrations operationsGetMigrationsCount operationsGetNonceRevelationByHash operationsGetNonceRevelations operationsGetNonceRevelationsCount operationsGetOriginationByHash operationsGetOriginationStatus operationsGetOriginations operationsGetOriginationsCount operationsGetPreendorsementByHash operationsGetPreendorsements operationsGetPreendorsementsCount operationsGetProposalByHash operationsGetProposals operationsGetProposalsCount operationsGetRegisterConstantByHash operationsGetRegisterConstantStatus operationsGetRegisterConstants operationsGetRegisterConstantsCount operationsGetRevealByHash operationsGetRevealStatus operationsGetReveals operationsGetRevealsCount operationsGetRevelationPenalties operationsGetRevelationPenaltiesCount operationsGetRevelationPenaltyById operationsGetSetDepositsLimitByHash operationsGetSetDepositsLimitStatus operationsGetSetDepositsLimits operationsGetSetDepositsLimitsCount operationsGetStatus operationsGetTransactionByHash operationsGetTransactionByHashCounter operationsGetTransactionByHashCounterNonce operationsGetTransactionStatus operationsGetTransactions operationsGetTransactionsCount operationsGetTransferTicketOps operationsGetTransferTicketOpsByHash operationsGetTransferTicketOpsCount operationsGetTransferTicketStatus operationsGetTxRollupCommitOps operationsGetTxRollupCommitOpsByHash operationsGetTxRollupCommitOpsCount operationsGetTxRollupCommitStatus operationsGetTxRollupDispatchTicketsOps operationsGetTxRollupDispatchTicketsOpsByHash operationsGetTxRollupDispatchTicketsOpsCount operationsGetTxRollupDispatchTicketsStatus operationsGetTxRollupFinalizeCommitmentOps operationsGetTxRollupFinalizeCommitmentOpsByHash operationsGetTxRollupFinalizeCommitmentOpsCount operationsGetTxRollupFinalizeCommitmentStatus operationsGetTxRollupOriginationOps operationsGetTxRollupOriginationOpsByHash operationsGetTxRollupOriginationOpsCount operationsGetTxRollupOriginationStatus operationsGetTxRollupRejectionOps operationsGetTxRollupRejectionOpsByHash operationsGetTxRollupRejectionOpsCount operationsGetTxRollupRejectionStatus operationsGetTxRollupRemoveCommitmentOps operationsGetTxRollupRemoveCommitmentOpsByHash operationsGetTxRollupRemoveCommitmentOpsCount operationsGetTxRollupRemoveCommitmentStatus operationsGetTxRollupReturnBondOps operationsGetTxRollupReturnBondOpsByHash operationsGetTxRollupReturnBondOpsCount operationsGetTxRollupReturnBondStatus operationsGetTxRollupSubmitBatchOps operationsGetTxRollupSubmitBatchOpsByHash operationsGetTxRollupSubmitBatchOpsCount operationsGetTxRollupSubmitBatchStatus operationsGetUpdateConsensusKeyByHash operationsGetUpdateConsensusKeyOps operationsGetUpdateConsensusKeyOpsCount operationsGetVdfRevelationByHash operationsGetVdfRevelations operationsGetVdfRevelationsCount protocolsGet protocolsGetByCode protocolsGetByCycle protocolsGetByHash protocolsGetCount protocolsGetCurrent quotesGet quotesGetCount quotesGetLast rewardsGetBakerRewards rewardsGetBakerRewardsByCycle rewardsGetBakerRewardsCount rewardsGetDelegatorRewards rewardsGetDelegatorRewardsByCycle rewardsGetDelegatorRewardsCount rewardsGetRewardSplit rewardsGetRewardSplitDelegator rightsGet rightsGetCount softwareGet softwareGetCount statisticsGet statisticsGetCycles statisticsGetCyclesAll statisticsGetDaily tokensGetTokenBalances tokensGetTokenBalances2 tokensGetTokenBalancesCount tokensGetTokenTransfers tokensGetTokenTransfersCount tokensGetTokens tokensGetTokensCount votingGetCurrentEpoch votingGetCurrentPeriod votingGetEpoch votingGetEpochs votingGetLatestVoting votingGetPeriod votingGetPeriodVoter votingGetPeriodVoter2 votingGetPeriodVoters votingGetPeriodVoters2 votingGetPeriods votingGetProposalByHash votingGetProposals votingGetProposalsCount

Generated using TypeDoc