Difference between revisions of "API"

From BiblePay Wiki
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
</p><p>We are offering an alternative to big tech, big media, and we are fighting for freedom.  Just as God wants freedom for us, we want freedom for you.  We do not believe in censoring free speech but the principles of the founding fathers.  Additionally, when you use our services, you are paying for orphan sponsorships.  What better relationship could there be?
 
</p><p>We are offering an alternative to big tech, big media, and we are fighting for freedom.  Just as God wants freedom for us, we want freedom for you.  We do not believe in censoring free speech but the principles of the founding fathers.  Additionally, when you use our services, you are paying for orphan sponsorships.  What better relationship could there be?
 
</p><p><br />
 
</p><p><br />
 +
 
Live Service #1:
 
Live Service #1:
 
</p><p><br />
 
</p><p><br />
 
<b> BiblePay S3 File Hosting (S3aas) </b>
 
<b> BiblePay S3 File Hosting (S3aas) </b>
 
</p><p>This API allows you to store files, accessible by public URL (via CDN).  You may store small files all the way up to very large files (1 byte to 1Gigabyte per file).
 
</p><p>This API allows you to store files, accessible by public URL (via CDN).  You may store small files all the way up to very large files (1 byte to 1Gigabyte per file).
</p><p>The storage is extremely cost effective, priced at&#160;:  1 bbp per 100 megabytes per month.
 
The files are available worldwide through our anti-ddos CDN which is located in all major cities and countries.
 
</p><p>Bandwidth costs: Zero.
 
 
</p><p>Use cases:  Upload your mp4 videos, your audio tracks, your encrypted backup files, your web site files, your images/css/assets for web hosting, share files etc.
 
</p><p>Use cases:  Upload your mp4 videos, your audio tracks, your encrypted backup files, your web site files, your images/css/assets for web hosting, share files etc.
 
</p><p><b> S3 Endpoint for Curl (Linux, Mac, others) </b>
 
</p><p><b> S3 Endpoint for Curl (Linux, Mac, others) </b>
Line 17: Line 15:
 
<pre>curl -X POST  
 
<pre>curl -X POST  
 
     -H "key: YOUR_BIBLEPAY_PRIVATE_KEY"  
 
     -H "key: YOUR_BIBLEPAY_PRIVATE_KEY"  
 +
    -H "url: Your_preferred_filename"
 
     -F "[email protected]"  
 
     -F "[email protected]"  
 
     https://unchained.biblepay.org/api/web/bbpingress
 
     https://unchained.biblepay.org/api/web/bbpingress
 
</pre>
 
</pre>
 +
Example:
 +
<pre>curl -X POST
 +
    -H "key: U1234567890"
 +
    -H "url: myfile.mp4"
 +
    -F "[email protected]"
 +
    https://unchained.biblepay.org/api/web/bbpingress
 +
</pre>
 +
 
<p><br />
 
<p><br />
 
Response:
 
Response:
Line 31: Line 38:
 
{
 
{
 
       string sURL = "https://unchained.biblepay.org/api/web/bbpingress";
 
       string sURL = "https://unchained.biblepay.org/api/web/bbpingress";
       string sFilePath = "s:\\san\\rapture2\\9.mp4";
+
       string sFilePath = "s:\\yourfolder\\filename.mp4";
 
       HttpContent bytesContent = new ByteArrayContent(System.IO.File.ReadAllBytes(sFilePath));
 
       HttpContent bytesContent = new ByteArrayContent(System.IO.File.ReadAllBytes(sFilePath));
 
       using (var httpClient = new System.Net.Http.HttpClient())
 
       using (var httpClient = new System.Net.Http.HttpClient())
Line 39: Line 46:
 
             httpClient.Timeout = new System.TimeSpan(0, 60, 00);
 
             httpClient.Timeout = new System.TimeSpan(0, 60, 00);
 
             httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 
             httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
             httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Key", "your_bbp_private_key");
+
             httpClient.DefaultRequestHeaders.TryAddWithoutValidation("key", "your_bbp_private_key");
 +
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("url", "your_filename");
 
             var multipartContent = new MultipartFormDataContent();
 
             var multipartContent = new MultipartFormDataContent();
 
             multipartContent.Add(bytesContent, "file", System.IO.Path.GetFileName(sFilePath));
 
             multipartContent.Add(bytesContent, "file", System.IO.Path.GetFileName(sFilePath));
Line 52: Line 60:
 
</p><p>Sample Response:
 
</p><p>Sample Response:
 
</p>
 
</p>
<pre>{"error":"","URL":"https://bbp.s3.filebase.com/BBSWt5B13GuM5xJQHYM468bLC5qxmRmQ7Y/9.mp4","result":200}
+
<pre>{"error":"","URL":"https://unchained.biblepay.org/BBSWt5B13GuM5xJQHYM468bLC5qxmRmQ7Y/9.mp4","result":200}
 
</pre>
 
</pre>
 
<p><br />
 
<p><br />
</p><p><br />
 
</p><p><b> BIPFS - BiblePay Immutable Public File System (BIPFSaas) </b>
 
</p><p>This API allows you to store provably immutable files, accessible by public URL (via CDN).  You may store small files all the way up to very large files (1 byte to 1Gigabyte per file).
 
</p><p>The storage is extremely cost effective, priced at&#160;:  1 bbp per 100 megabytes per month.
 
The files are available worldwide through our anti-ddos CDN which is located in all major cities and countries.
 
</p><p>Bandwidth costs: Zero.
 
</p><p>Use cases:  NFT metadata files, contract data, special social media posts, provable timestamped videos, or any file that needs immutability.
 
</p><p>How it is immutable: 
 
First, we hash the file with a standard sha256 hash.
 
We require the sha256 hash to become the filename.  The filename extension is preserved.
 
Once the file is stored, we create an immutable biblepay transaction pointing to the file which contains the sha256 hash (this permanently preserves the timestamp and the record).
 
The file contents can never be changed (because it can always be proven the hash matches) except in the case of non-payment.
 
In the case of nonpayment, the contents of the file will be served as "UNPAID" and the blockchain record of the file will remain intact.
 
</p><p><b> S3 Endpoint for Curl (Linux, Mac, others) </b>
 
</p><p>Simply post your file from the command or through code as below, along with your biblepay private key in the Header field:
 
</p><p>Example:
 
</p>
 
<pre>curl -X POST
 
    -H "key: YOUR_BIBLEPAY_PRIVATE_KEY"
 
    -H "immutable: 1"
 
    -F "file.mp4"
 
    https://unchained.biblepay.org/api/web/bbpingress
 
</pre>
 
<p><br />
 
Response:
 
</p><p>If successful, Biblepay will respond with an http-200 response, with JSON containing an empty error field, a result code with a value of 200, and the URL which you can use immediately.
 
If unsuccessful, BiblePay will respond with an http-200 response, with JSON containing an error field with a populated reason, and a result code below zero.
 
 
</p><p><br />
 
</p><p><br />
 
</p><p><br />
 
</p><p><br />
 
</p><p><br />
 
</p><p><br />
 +
 +
 +
<h3>Live Service #2 - Database</h3>
 +
<br>
 +
<br>
 +
You can use biblepay to set and retrieve database values for your personal use.
 +
From the BiblePay Core RPC client, you can set or retrieve a value.
 +
 +
'''Set Database Value'''
 +
 +
setdatabasevalue my_bbp_privkey table key value
 +
 +
BiblePay will respond with either an error or success.
 +
 +
 +
''' Retrieve database value '''
 +
 +
getdatabasevalue my_bbp_privkey table key
 +
 +
BiblePay will respond with the value of the key.
 +
 +
 +
''' How do I generate a storage keypair? '''
 +
 +
generatestoragetoken
 +
 +
''' How do I retrieve my current monthly billing assessment? '''
 +
 +
getstoragebalance bbp_pub_key
 +
 +
 +
 +
 +
 
</p><p><b>FAQ</b>
 
</p><p><b>FAQ</b>
 
</p><p><br />
 
</p><p><br />

Latest revision as of 12:29, 2 December 2022


We are a blockchain with real world use cases.

We are offering an alternative to big tech, big media, and we are fighting for freedom. Just as God wants freedom for us, we want freedom for you. We do not believe in censoring free speech but the principles of the founding fathers. Additionally, when you use our services, you are paying for orphan sponsorships. What better relationship could there be?


Live Service #1:


BiblePay S3 File Hosting (S3aas)

This API allows you to store files, accessible by public URL (via CDN). You may store small files all the way up to very large files (1 byte to 1Gigabyte per file).

Use cases: Upload your mp4 videos, your audio tracks, your encrypted backup files, your web site files, your images/css/assets for web hosting, share files etc.

S3 Endpoint for Curl (Linux, Mac, others)

Simply post your file from the command or through code as below, along with your biblepay private key in the Header field:

Example:

curl -X POST 
    -H "key: YOUR_BIBLEPAY_PRIVATE_KEY" 
    -H "url: Your_preferred_filename"
    -F "[email protected]" 
    https://unchained.biblepay.org/api/web/bbpingress

Example:

curl -X POST 
    -H "key: U1234567890" 
    -H "url: myfile.mp4"
    -F "[email protected]" 
    https://unchained.biblepay.org/api/web/bbpingress


Response:

If successful, Biblepay will respond with an http-200 response, with JSON containing an empty error field, a result code with a value of 200, and the URL which you can use immediately.

If unsuccessful, BiblePay will respond with an http-200 response, with JSON containing an error field with a populated reason, and a result code below zero.


S3 Endpoint for C#

You can also post your file programatically in any language. For C#, please see this example below:

public async static void UploadBiblePayFile()
{
      string sURL = "https://unchained.biblepay.org/api/web/bbpingress";
      string sFilePath = "s:\\yourfolder\\filename.mp4";
      HttpContent bytesContent = new ByteArrayContent(System.IO.File.ReadAllBytes(sFilePath));
      using (var httpClient = new System.Net.Http.HttpClient())
      {
        using (var request = new HttpRequestMessage(new HttpMethod("POST"), sURL))
        {
            httpClient.Timeout = new System.TimeSpan(0, 60, 00);
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("key", "your_bbp_private_key");
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("url", "your_filename");
            var multipartContent = new MultipartFormDataContent();
            multipartContent.Add(bytesContent, "file", System.IO.Path.GetFileName(sFilePath));
            request.Content = multipartContent;
            var oInitialResponse = await httpClient.PostAsync(sURL, multipartContent);
            string sJsonResponse = await oInitialResponse.Content.ReadAsStringAsync();
        }
    }
}


Sample Response:

{"error":"","URL":"https://unchained.biblepay.org/BBSWt5B13GuM5xJQHYM468bLC5qxmRmQ7Y/9.mp4","result":200}






Live Service #2 - Database



You can use biblepay to set and retrieve database values for your personal use. From the BiblePay Core RPC client, you can set or retrieve a value.

Set Database Value

setdatabasevalue my_bbp_privkey table key value

BiblePay will respond with either an error or success.


Retrieve database value

getdatabasevalue my_bbp_privkey table key

BiblePay will respond with the value of the key.


How do I generate a storage keypair?

generatestoragetoken

How do I retrieve my current monthly billing assessment?

getstoragebalance bbp_pub_key



FAQ


Q: Where are my files stored and what is the durability?

A: The network is comprised of three partners: BiblePay (for metadata), BiblePay Sanctuaries, IPFS, and CDN (for retrieval). The durability is set higher than normal so that the files will never be deleted unless you fail to pay the BBP hosting fee.


Q: What is a CDN?

A: A content data network copies your file to hundreds of global POPs (Points of Presence) so that the file can be downloaded faster to your user. This also provides resilience, in case the file is attempted to be taken down due to censorship, your file will still be available. Also if a fiber optic line is cut in a certain area, your file will still be available to the rest of the world. The CDN also provides anti-ddos, meaning that the CDN network is larger than any potential ddos threat. A good use case for a CDN is a news article. If you host it on biblepay, even if the article is attacked by thousands of malicious botnet actors, our CDN will keep supplying that news article to your readers. News orgs already use CDNs for their articles.


Q: How does billing work?

A: Once per month, we bill your private key for the sum in size of the bytes hosted for that key to the key itself so please ensure your key has enough to cover future hosting. We create an invoice that may be viewed in My Invoices. If your key does not have enough funds to cover the fees, after the grace period elapses (+14 days), then the files that cannot be paid for will be deleted. Other files in good standing will stay hosted.


Q: Why shouldn't I go directly to STORJ or Amazon?

A: For STORJ, you will find that you need to setup a lot of technical items such as your download gateway and you will need to deal with the command line to send and receive files while we offer a programmatic solution above. We also do all the technical work for you to make it easier for you. Additionally, you dont get a free CDN. With Amazon, you are dealing with big tech, who will definitely charge you for all public bandwidth consumption which could cost you more than BiblePay. For example if your file is abused (repeatedly downloaded millions of times you could end up with a very high S3 invoice). With BiblePay, we only charge for the storage. Finally, with BiblePay you are helping ORPHANS. It's easy to decide when you want to make the world a better place.


Q: What if I want my data private and not public, like a backup file?

A: Reach out to us on social.biblepay.org and ask for the feature and if the demand is there, we will add an encryption option for you so that your data at rest file in cloud is encrypted with your key.