Associate
Hi all, so I'm quite new to this api stuff.
Im trying to get some bitcon exchange data from coinApi using flutter / dart and I keep getting a response 401
So I'm fairly sure it's the url that I'm sending is wrong in some way but I just can't work out the full URL should be. As you
can probably tell I'm trying to get back the cost of 1 bitcoin in USD, I will want to get it in other currencies as well.
Could someone please take a look at the link below and tell me what I should be sending.
Thanks
coinapi
EDIT : I've sorted it
I should have parsed this : https://rest.coinapi.io/v1/exchangerate/BTC/USD?apikey=$apiKey
basically missed the ? out ( doh )
this is my code
Im trying to get some bitcon exchange data from coinApi using flutter / dart and I keep getting a response 401
So I'm fairly sure it's the url that I'm sending is wrong in some way but I just can't work out the full URL should be. As you
can probably tell I'm trying to get back the cost of 1 bitcoin in USD, I will want to get it in other currencies as well.
Could someone please take a look at the link below and tell me what I should be sending.
Thanks
coinapi
EDIT : I've sorted it
I should have parsed this : https://rest.coinapi.io/v1/exchangerate/BTC/USD?apikey=$apiKey
basically missed the ? out ( doh )
this is my code
Code:
import 'package:http/http.dart' as http;
const coinAPI2 = 'https://rest.coinapi.io/v1/exchangerate/BTC/USD';
const apiKey = 'MY API KEY'; // obviously I am using my actual api key
class CoinData {
Future getCoinData() async {
var url = Uri.parse('$coinAPI2$apiKey');
http.Response response = await http.get(url);
if (response.statusCode == 200) {
print(response.body);
} else {
print('response was ${response.statusCode}');
}
}
}
Last edited: