From c7484fd7c01fd8016f4e078864726724a2a3c0e5 Mon Sep 17 00:00:00 2001 From: Ruben van Erk Date: Fri, 22 May 2020 10:50:19 +0200 Subject: [PATCH] Use api.coinstats.app for currency prices --- src/app/services/price.service.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/services/price.service.ts b/src/app/services/price.service.ts index 07f18d94..6bf0d6cd 100644 --- a/src/app/services/price.service.ts +++ b/src/app/services/price.service.ts @@ -4,7 +4,7 @@ import {BehaviorSubject} from "rxjs/BehaviorSubject"; @Injectable() export class PriceService { - apiUrl = `https://api.coinmarketcap.com/v1/`; + apiUrl = `https://api.coinstats.app/public/v1/`; price = { lastPrice: 1, @@ -16,16 +16,15 @@ export class PriceService { async getPrice(currency = 'USD') { if (!currency) return; // No currency defined, do not refetch - const convertString = currency !== 'USD' && currency !== 'BTC' ? `?convert=${currency}` : ``; - const response: any = await this.http.get(`${this.apiUrl}ticker/nano/${convertString}`).toPromise(); + const convertString = currency !== 'USD' && currency !== 'BTC' ? `?currency=${currency}` : ``; + const response: any = await this.http.get(`${this.apiUrl}coins/nano${convertString}`).toPromise(); if (!response || !response.length) { return this.price.lastPrice; } const quote = response[0]; - const currencyPrice = quote[`price_${currency.toLowerCase()}`]; - const btcPrice = quote.price_btc; - const usdPrice = quote.price_usd; + const currencyPrice = quote.price; + const btcPrice = quote.priceBtc; this.price.lastPrice = currencyPrice; this.price.lastPriceBTC = btcPrice;