0171 - Rejected - Standards - March 4, 2017 (9 years, 4 months ago)
4
2017
BIP: 171
Layer: Applications
Title: Currency/exchange rate information API
Author: Luke Dashjr <[email protected]>
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 171
Status: Rejected
Type: Standards Track
Created: 2017-03-04
License: BSD-2-Clause
A common interface for requesting currency exchange rate information from a server.
This BIP is licensed under the BSD 2-clause license.
Four requests are defined, which are all made by a GET request to a common URI with parameters encoded in application/x-www-form-urlencoded format. All matching parameters may be specified with multiple comma-separated values, which are to be interpreted as "any of these". Each result is always in JSON format, with a line-feed (never a carriage-return) separating multiple results.
Authentication for subscription-based services MAY be supported using standard HTTP authentication. It is recommended to use TLS (HTTPS) and/or Linked Data Signatures, so that MITM attackers cannot deceive the client.
To be BIP 171 compatible, servers MUST support at least one currency-pair compared to XBT. All inquiries for bitcoin amounts MUST be specified in XBT, even if the presentation to the end user is in another unit. (FIXME: or should this be satoshis?)
Currency-pair tokens are arbitrary Strings no longer than 255 characters, which may include any ASCII RFC 3986 unreserved characters (ie, alphanumerics and the hyphen, underscore, period, and tilde symbols).
Currency code(s) used herein are defined as such:
Rate is defined as the amount of quote-currency to be exchanged for
one unit of the base-currency. In other words,
1 baseCurrency = rate quoteCurrency
.
Parameters:
Each currency-pair will receive a separate result, a JSON Object, with the following information:
Example:
Request:
http://api.example.tld/?mode=list"e=USD&base=XBT&locale=en_US,en_GB
Result:
{"cp":"XBTUSD-ver4", "quote":"USD", "base": "XBT", "locale": "en_US", "desc": "Smoothed averages"}
{"cp":"2", "quote":"USD", "base": "XBT", "locale": "en_US", "desc": "Updated per-trade"}
{"cp":"XBTUSD-european", "quote":"USD", "base": "XBT", "locale": "en_GB"}
Parameters:
Each currency-pair will receive a separate result, a JSON Object, with the following information:
[3, ",", 0]
Example:
Request:
http://api.example.tld/?mode=info&cp=XBTUSD-ver4,2
Result:
{"cp":"XBTUSD-ver4", "quote":"USD", "base": "XBT", "locale": "en_US", "desc": "Smoothed averages", "longdesc": "USD price quotes as compared to Bitcoin value\n\nRecommended for casual usage", "symbol": [["-$", "$"], null], "digits": "arabic", "grouping": [3, ",", 0], "fraction_sep": ".", "fraction_digits": [0, 2, 2], "minpoll": 300, "longpoll": true, "history": 1457231416}
{"cp":"2", "quote":"USD", "base": "XBT", "locale": "en_US", "desc": "Updated per-trade", "longdesc": "Maximum precision USD price quotes as compared to Bitcoin value", "symbol": [["-$", "$"], null], "digits": "arabic", "grouping": [3, ",", 0], "fraction_sep": ".", "fraction_digits": [0, 2, 2], "minpoll": 3600, "longpoll": false, "history": 1467458333.1225}
Parameters:
Each currency-pair receives a separate result (a JSON Object) with all requested rate types:
Example:
Request:
http://api.example.tld/?mode=rate&cp=XBTUSD-ver4,2&type=typical,high
Result:
{"cp":"XBTUSD-ver4", "time": 1488767410.5463133, "rates": {"typical": 1349.332215, "high": 1351.2}}
{"cp":"2", "time": 1488767410, "rates": {"typical": 1350.111332}}
Parameters:
A result is provided for each currency-pair and timestamp record, in the same format as the current exchange rate request. Records MUST be provided in chronological order, but only within the scope of the applicable currency-pair (ie, it is okay to send the full history for one currency-pair, and then the full history for the next; or to intermix them out of any given order).
If there is no exact record for the times specified by "from" and/or "to", a single record before "from" and/or after "to" should also be included. This is not necessary when only the nearest record is requested, or when "to" is omitted (ie, ending at the most recent record).
Example:
Request:
http://api.example.tld/?mode=history&cp=XBTUSD-ver4,2&type=typical&ratedelta=0.1&timedelta=10&from=1488759998&to=1488760090
Result:
{"cp":"XBTUSD-ver4", "time": 1488760000, "rates": {"typical": 1300}}
{"cp":"XBTUSD-ver4", "time": 1488760010, "rates": {"typical": 1301.1}}
{"cp":"XBTUSD-ver4", "time": 1488760020, "rates": {"typical": 1320}}
{"cp":"XBTUSD-ver4", "time": 1488760030, "rates": {"typical": 1305}}
{"cp":"2", "time": 1488760000.1, "rates": {"typical": 1300}}
{"cp":"2", "time": 1488760010.2, "rates": {"typical": 1301.1}}
{"cp":"2", "time": 1488760020.2, "rates": {"typical": 1320.111332}}
{"cp":"2", "time": 1488760031, "rates": {"typical": 1305.222311}}
{"cp":"XBTUSD-ver4", "time": 1488760040, "rates": {"typical": 1303.33}}
{"cp":"2", "time": 1488760042, "rates": {"typical": 1303.33}}
{"cp":"XBTUSD-ver4", "time": 1488760050, "rates": {"typical": 1305}}
{"cp":"2", "time": 1488760052, "rates": {"typical": 1307}}
{"cp":"XBTUSD-ver4", "time": 1488760060, "rates": {"typical": 1309}}
{"cp":"XBTUSD-ver4", "time": 1488760072, "rates": {"typical": 1308}}
{"cp":"2", "time": 1488760062, "rates": {"typical": 1309.55555555}}
{"cp":"2", "time": 1488760072, "rates": {"typical": 1308}}
{"cp":"XBTUSD-ver4", "time": 1488760082, "rates": {"typical": 1309}}
{"cp":"2", "time": 1488760082, "rates": {"typical": 1309.1}}
End users often desire to see fiat currency information in their Bitcoin wallet software. Due to the nature of Bitcoin, there is inherently no authoritative source for exchange rates. There are many independent providers of such information, but they all use different formats for providing it, so wallet software is currently forced to implement dedicated code for each provider.
By providing a standard interface for retrieving this information, wallets (and other software) and service providers can implement it once, and become immediately interoperable with all other compatible implementations.
Why are multiple results separated by a line-feed rather than using a JSON Array?
What if long descriptions require line and paragraph breaks?
While this new standard is adopted, software and providers can continue to use and provide their current formats until they are no longer needed.
TODO