BRC20 endpoints unable to read array of string in query params
i can't seem to get any results returned back from this BRC-20 API endpoint when passing in tickers as an array of strings:
curl example:
curl -X GET "https://api.hiro.so/ordinals/v1/brc-20/tokens?ticker=%5B%22piza%22%2C%22pepe%22%5D"
js fetch example:
const baseUrl = "https://api.hiro.so/ordinals/v1/brc-20/tokens"
const params = new URLSearchParams({
ticker: ["piza", "pepe"]
})
const urlWithParams = `${baseUrl}?${params.toString()}`
let result = await fetch(urlWithParams, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json"
}
})
let response = await result.json()
console.log(response)
response: {"limit":20,"offset":0,"total":0,"results":[]}
ref: https://docs.hiro.so/bitcoin/ordinals/api/brc20/get-brc20-tokens (e
There is an issue with the docs output and it was flagged in this issue https://github.com/hirosystems/bitcoin-indexer/issues/538, it will be fixed in the future.
The right format for this curl is:
curl -X GET "https://api.hiro.so/ordinals/v1/brc-20/tokens?ticker=piza&ticker=pepe"
The js fetch example would become:
const baseUrl = "https://api.hiro.so/ordinals/v1/brc-20/tokens";
// Append multiple `ticker` parameters manually
const params = new URLSearchParams();
params.append("ticker", "piza");
params.append("ticker", "pepe");
const urlWithParams = `${baseUrl}?${params.toString()}`;
let result = await fetch(urlWithParams, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json"
}
});
let response = await result.json();
console.log(response);