I am building an MERN stack app cardano dex tool, I want to use Blockfrost.

I have installed the SDK in Node.js backend, but there are only very few examples on how to get any kind of data from it.

The Blockfrost documentation gives more info and I know how to use it with fetch, but only url based and don't know how to implement QUERY PARAMETERS into the url request. Here is an example.

function getAssets(){
            headers: {
                "project_id":'API KEY'

If there is someone that could explain me a bit how to start using Blockfrost the proper way with a Node.js backend and basically get any kind of information.

Or maybe there is a better solution to get all data from the Cardano network, I have an relay node running with GraphQL, but getting data from that is very difficult if you just starting to use it and I don't know if it will keep working after the Alonzo fork.

Please someone that can help me pointing the right direction would be awesome.

1 Answer 1


Using the Blockfrost SDK is pretty straight forward, as in this example:

import { BlockFrostAPI } from '../src/index';

async function run() {
  const API = new BlockFrostAPI({
    projectId: 'YOUR API KEY HERE', // see: https://blockfrost.io

  try {
    const latestBlock = await API.blocksLatest();
    const latestEpoch = await API.epochsLatest();
    const health = await API.health();
    const address = await API.addresses(

    console.log('address', address);
    console.log('latestEpoch', latestEpoch);
    console.log('latestBlock', latestBlock);
    console.log('health', health);
  } catch (err) {
    console.log('error', err);


Basically you can use any of Blockfrost endpoints in the SDK as well, check out the list of available calls. I recommend you using an IDE such as codium as it will autofill these as you code.

  • 1
    Hey, thank you for the reply. Well you are right the wiki you show is very clear. Somehow I missed the right menu to get more specific info. Aug 30, 2021 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.