-1

So I'm trying to import Cardano Blockchain data like address balance, amount staked, rewards etc into a Google Sheet. I found this project named Blockfrost.io which is an API for accessing Cardano blockchain info and import it into apps etc.

I think I can use this with Google Sheets. Problem is I don't know how to authenticate. I've searched all around on the documentation and it's not clear to me. It seems it's possible if your're building an app or using the terminal.

But I just want to authenticate in the easiest way possible like in the browser address bar that way it would be simple to get the JSON with the info I need and import the info to Google Sheets.

This is where it mentions the Authentication: https://docs.blockfrost.io/#section/Authentication

I already have an API key to access. But how do I authenticate?

So if I want to check the blockchain metrics (mainnet1234567890 is a dummy key, I won't use mine here):

https://cardano-mainnet.blockfrost.io/api/v0/metrics/project_id:mainnet1234567890

The JSON will still output this:

status_code 403
error   "Forbidden"
message "Missing project token. Please include project_id in your request."

Is there a correct way to authenticate on the browser address bar?

Verminous
  • 490
  • 3
  • 14

2 Answers2

1

It's not clear which BlockFrost API you are using Go JavaScript etc...

the API key goes in as a header on the request object. I was manually trying to connect to the service and found for a request is what I had to do in C#...

var aWR = System.Net.WebRequest.Create(url);
aWR.Method = "GET";
aWR.Headers.Add("project_id", "mainnetTheRestOfMyKeyIsHidden");
var webResponse = aWR.GetResponse();
var webStream = webResponse.GetResponseStream();
var reader = new StreamReader(webStream);
var data = reader.ReadToEnd(); 

Later I realized I wanted to use their API cause they implement the rate limiter, something I would rather use than build... I use the following with the BlockFrost API in c#

const string apiKey = "mainnetPutYourKeyHere";
const string network = "mainnet";
// your key is set during the construction of the provider.
ServiceProvider provider = new ServiceCollection().AddBlockfrost(network, apiKey).BuildServiceProvider();
// from there individual services are created
 var AddressService = provider.GetRequiredService<IAddressesService>();
// The call to get the data looked like
AddressTransactionsContentResponseCollection TXR = await AddressService.GetTransactionsAsync(sAddress, sHeightFrom, sHeightTo, 100, iAddressPage, ESortOrder.Desc, new System.Threading.CancellationToken());
// etc. your gonna need to set the bounds above in terms of block height
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
Mattei
  • 11
  • 4
0

Try using postman and include the "project_id" header with api key as the value like this - it will clear up the concept for you I think:enter image description here

RelevantData
  • 101
  • 1