Files
oemanxTrader/OemanTrader.FinantialModelingPrepAPI/FinancialModelingPrepHttpClient.cs
2022-05-26 15:19:31 +02:00

32 lines
1022 B
C#

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
namespace OemanTrader.FinantialModelingPrepAPI
{
public class FinancialModelingPrepHttpClient : HttpClient
{
private readonly string _apiKey;
public FinancialModelingPrepHttpClient(string apiKey)
{
this.BaseAddress = new Uri("https://financialmodelingprep.com/api/v3/");
_apiKey = apiKey;
}
public async Task<T> GetAsync<T>(string uri)
{
// HttpResponseMessage response = await GetAsync(uri + "?apikey=2035d4934632e1d7c38f15982e39d3aa");
//var apikey = "2035d4934632e1d7c38f15982e39d3aa";
HttpResponseMessage response = await GetAsync($"{uri}?apikey={_apiKey}");
string jsonResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(jsonResponse);
}
}
}