This repository is an ongoing collection of useful APIs generated by bqb (bitquery builder)
It's a pre-written query recipe for interacting with some useful protocols.
So far included:
- memo.cash
You can also fetch the query directly from this repository and make a request from the fetched JSON, instead of downloading it in your app folder
Node.js:
const api = require('./memo.json')
const fetch = require('node-fetch')
// Fetch Bitquery from Github
fetch("https://21centurymotorcompany.github.io/api/endpoint/memo.json").then(function(api) {
// Fetch the actual API via Bitquery
fetch(api.prod.memo.post).then(function(res) {
return res.json()
}).then(function(res) {
console.log(res)
})
})
Browser:
<html>
<script>
// Fetch Bitquery from Github
fetch("https://21centurymotorcompany.github.io/api/endpoint/memo.json").then(function(api) {
// Fetch the actual API via Bitquery
fetch(api.prod.memo.post).then(function(res) {
return res.json()
}).then(function(res) {
document.write(JSON.stringify(res, null, 2))
})
})
</script>
</html>
Because the API contains both the raw query as well as the base64 compiled, you can always check the authenticity by testing the equality:
<html>
<script>
// Fetch Bitquery from Github
fetch("https://21centurymotorcompany.github.io/api/endpoint/memo.json").then(function(api) {
// Fetch the actual API via Bitquery
var compiled = btoa(JSON.stringify(api.dev.memo.post));
var is_authentic = (compiled === api.prod.memo.post);
documet.write("Is the prod query authentic? " + is_authentic)
})
</script>
</html>
You could also download the JSON under the api
folder into your app folder and use it locally.
Just copy the JSON inside the api
folder into your app folder, for example save it as "memo.json"
.
Require from app and use it
Node.js:
const api = require('./memo.json')
const fetch = require('node-fetch')
fetch(api.memo.post).then(function(res) {
return res.json()
}).then(function(res) {
console.log(res)
})