Skip to main content

Javascript


koios-api-python

Overview

A Javascript package for the Cardano Blockchain Koios API

Install MeshJS package

Tips

npm install @meshsdk/core @meshsdk/react

Examples

Below there are few examples to study, while to see the full koios-javascript documentation you can find it here

Fetch Account Info
// Import the KoiosProvider library
import KoiosProvider from 'koios-provider';

// Create a new KoiosProvider instance for the mainnet network
const koiosProvider = new KoiosProvider('mainnet');

// Fetch account information for a specific address
const address = 'stake_test1uzx0ksy9f4qnj2mzfdncqyjy84sszh64w43853nug5pedjgytgke9';
koiosProvider.fetchAccountInfo(address)
.then((accountInfo) => {
console.log(Account information for address ${address}:, accountInfo);
})
.catch((error) => {
console.error(Error fetching account information for address ${address}:, error);
});

// Fetch UTXOs for a specific address
const utxoAddress = 'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr';
const asset = 'd9312da562da182b02322fd8acb536f37eb9d29fba7c49dc172555274d657368546f6b656e';
koiosProvider.fetchAddressUTxOs(utxoAddress, asset)
.then((utxos) => {
console.log(UTXOs for address ${utxoAddress} and asset ${asset}:, utxos);
})
.catch((error) => {
console.error(Error fetching UTXOs for address ${utxoAddress} and asset ${asset}:, error);
});

// Fetch a list of addresses containing a specific asset
koiosProvider.fetchAssetAddresses(asset)
.then((addresses) => {
console.log(Addresses containing asset ${asset}:, addresses);
})
.catch((error) => {
console.error(Error fetching addresses containing asset ${asset}:, error);
});