Skip to content

fountainhead-cash/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

API

This repository is an ongoing collection of useful APIs generated by bqb (bitquery builder)

What is this?

It's a pre-written query recipe for interacting with some useful protocols.

So far included:

  1. memo.cash

Quickstart

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>

Verifying Authenticity

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>

Local Usage

You could also download the JSON under the api folder into your app folder and use it locally.

Step 1.

Just copy the JSON inside the api folder into your app folder, for example save it as "memo.json".

Step 2.

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)
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published