The Blob object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
Retrieve blob
POSThttps://api.bloqifi.com/v0/blob
Retrieve a blob
Headers
Name
Type
Description
Content-Type
String
application/json
Request Body
Name
Type
Description
txids*
Array
List of transaction id's ['123', '321']
blockchain*
String
Bloqcoin, Dogecoin, Bitcoin
Returns a hex string compressed with Brotli which contains
a concatenation of all of the data in the array passed into the constructor.
Take a look at how you might call this method using our official libraries, or via curl:
const rawResponse = await fetch('https://api.bloqifi.com/v0/blob', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
blockchain: 'Bloqcoin',
txids: ['123', '321']
})
});
const result = await rawResponse.text();
if (rawResponse.status === 200) {
const fromHexString = hexString => Uint8Array.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
const compressedData = fromHexString(result);
// data contains the raw brotli compressed data
const decompressedData = brotli.decompress(compressedData);
const textDecoder = new TextDecoder();
console.log( textDecoder.decode(decompressedData) );
}
The output received from this endpoint is immutable, raw data compressed using Brotli
Good to know: Notice that the Blockchain string used is capitalized, this is required.
In the example we will be using Bloqcoin, other supported blockchains are:
Dogecoin, Bitcoin
Brotli is a lossless data compression algorithm developed by Google. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd order context modelling.
Install using NPM.
npm install brotli-wasm
A reliable compressor and de-compressor for Brotli, supporting node & browsers via wasm
In node.js:
const * as brotli = require('brotli-wasm');
const compressedData = brotli.compress(Buffer.from('some input'));
const decompressedData = brotli.decompress(compressedData);
console.log(Buffer.from(decompressedData).toString('utf8')); // Prints 'some input'
In browsers:
import brotliPromise from 'brotli-wasm'; // Import the default export
const brotli = await brotliPromise; // Import is async in browsers due to wasm requirements!
const compressedData = brotli.compress(Buffer.from('some input'));
const decompressedData = brotli.decompress(compressedData);
console.log(Buffer.from(decompressedData).toString('utf8')); // Prints 'some input'
JavaScript Node
To construct a Blob from transaction ids, you can also use Bloqifi JavaScript Node:
Bloqcoin very fast. Dogecoin much reliable, Wow. // One line of code is all it takes.
One line of code is all it takes to use images, text and more on your own website.
Include the Bloqifi JavaScript node on your site, and define your image tags:
// Get data as Blob
<img class="Bloqcoin" type="blob" data-src="txids" data-mimetype="image/png" style="visibility:hidden;" />
// Retrieve data Chunked
<img class="Bloqcoin" type="chunk" data-src="txids" data-mimetype="image/png" style="visibility:hidden;" />
// Or utilize Dogecoin as blockchain
<img class="Dogecoin" type="blob" data-src="txids" data-mimetype="image/png" style="visibility:hidden;" />
<img class="Dogecoin" type="chunk" data-src="txids" data-mimetype="image/png" style="visibility:hidden;" />
// Even IPFS
<img class="IPFS" type="blob" data-src="hash" data-mimetype="image/png" style="visibility:hidden;" />
<img class="IPFS" type="chunk" data-src="hash" data-mimetype="image/png" style="visibility:hidden;" />
Join all your bloq transaction ids (txid) as one comma separated string, and add it as data-src on an image tag to show the image.
If you add images dynamically, you can hook up to the "ready" event
function listener(e) {
window.hook('Bloqcoin');
window.hook('Dogecoin');
window.hook('Bitcoin');
window.hook('IPFS');
}
// worker not ready to receive postMessage
// IndexedDB might have the content
document.addEventListener('dbReady', listener, false);
// node ready to fetch
document.addEventListener('nodeReady', listener, false);
You can also have text containers. They work the same way as images as shown on the example below:
// Get data as Blob
<pre class="Bloqcoin" type="blob" data-src="txids" data-mimetype="text/plain"></pre>
// Retrieve data Chunked
<pre class="Bloqcoin" type="chunk" data-src="txids" data-mimetype="text/plain"></pre>
HEAD
The HTTP HEAD method requests the headers that would be returned if the HEAD request's URL was instead requested with the HTTP GET method.
The Blob object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
Retrieve blob
GEThttps://storage.bloqifi.com/ipfs/CID
Retrieve a blob
Returns plain raw data which contains
a concatenation of the cid passed into the constructor.
Good to know: The integrity and crossorigin attributes are used for . This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libraries are loaded from a third-party source. Read more at
For example, if a request might produce a large download, a HEAD request could read its header to check the file-size without actually downloading the file.