Buy 50+ APIs with Bitcoin in the 21 Marketplace
by Michael Goldstein, Eli Haims, John Granata, Justin P. O’Brien, Tyler Julian, Matt Storus, Mariano Rodriguez, and Balaji S. Srinivasan
As of today, if you have a 21 Bitcoin Computer or have early access to our free client, you can now buy 50+ paid APIs for bitcoin in the 21 Marketplace without any credit card, signup, or API key. Here are some of the things you can do:
- Translate text, identify a language in text, convert it to speech, or do optical character recognition
- Find related articles from the news, Wikipedia, Pubmed, or ArXiV
- Tag images and faces
- Validate emails and get information on companies
- Parse web text to automatically extract authors, titles, images, and links
- Apply natural language processing to text, like sentiment analysis and concept/entity/relation/keyword detection
- Convert between file types, like HTML to PDF or RSS to JSON
- Calculate metrics and parse tags from URLs
- Chain these kinds of paid APIs from different services together seamlessly, and sell the composite for bitcoin
There’s plenty more to come, but this is a fun initial set to play around with. If there’s a particular paid API group you’d like to see more heavily represented, like machine learning or mapping, please let us know in our Slack channel at slack.21.co. Alternatively, you can self-publish any API you want to see using 21 publish!
Buy APIs for bitcoin at the command line
Let’s show a quick example of how buying a machine-payable API works at the command line of a Bitcoin Computer. We update to the latest version of 21, mine a few satoshis and then use that balance to purchase an API call:
This API call uses a mapping service under the hood to find the latitude and longitude of the given street address specified as a string. It is priced at 0.5 cents per call, which is the per-request price of the underlying mapping service at $400 per BTC.
Buy APIs for bitcoin within a program
We can also buy APIs from the 21 marketplace within a Python program as follows:
Notice that no signup or API key was necessary! The only thing needed was the local bitcoin wallet used by the two1 library. Roughly speaking, we’ve replaced the login/password/credit card combination that is normally required for API signup with a public address/private key/bitcoin balance combination. The major advantage here is that your bitcoin wallet is essentially providing your login and payment credentials and thereby obviating the need for API signup.
Here’s another example that uses on-chain rather than off-chain payments, where we’re buying a face recognition API call:
We see that this image corresponds to the visage of Marc Andreessen from the Freebase database. Again, no login was needed to buy this API call. You just need the 21 software and a sufficient local bitcoin balance.
Buy thousands of API calls for bitcoin with micropayment channels
This will iterate over a range of zip codes and invoke the API on each call. There is one limitation: right now, you will need a deposit transaction on an API-by-API basis. But soon you’ll be able to put down one payment channel deposit transaction to buy from all 21.co APIs.
Chain multiple bitcoin-payable APIs together
Because it’s now so easy to buy APIs, we can chain multiple paid API calls together as follows:
Note that this program uses three different machine learning APIs and composes them to translate an image of Chinese text into audio of spoken English speech. Here’s how that pipeline looks (you can click to zoom in):
And here is the output sound, generated from OCR of the sign, followed by translation to English, followed by text to speech synthesis:
By convention, we name this kind of composite API after the first and last functions in the pipeline, which in this case would be ocr2speech21. You can clone and run this sample program here.
Sell composite APIs for bitcoin
Finally, we can take the composite API we just created and post that to the 21 micropayments marketplace as follows:
Here’s a way to understand that pipeline visually; go ahead and click to zoom in:
Note that if you look at the source of this example we set the price of ocr2speech-server.py as the sum of the prices of the individual APIs in the chain, along with a small margin on top. This is a very simple example of how you can start composing paid APIs built by others to create your own value-added machine-payable APIs, in a kind of digital supply chain.
The rise of mobile has vastly increased the number of APIs. Every nontrivial app these days is designed API first, such that it can provide data to multiple clients like phones, tablets, and desktops.
But it’s still quite painful to manage the credentials for an application with many APIs. And, relatedly, it’s hard to monetize anything but the most mission critical APIs. That’s because the primary cost of buying an API is often not the per-invocation cost of running the API, which can be in fractions of a cent; instead, it’s the fixed cost in developer time and energy of signing up for it.
With the 21 bitcoin wallet and the concept of a machine-payable API, we can obviate many of these concerns and start working with paid APIs in a new way. The steps are as follows:
- Get some bitcoin into your local 21 wallet
- Use 21 to call any listed paid API without signup or credit card
- Compose paid APIs to create new ones, and sell these