30 lines
856 B
C#
30 lines
856 B
C#
namespace Polygon.Client;
|
|
|
|
using System.Net.Http;
|
|
using System.Text.Json;
|
|
|
|
public partial class PolygonClient
|
|
{
|
|
/// <summary>
|
|
/// The HttpClient instance used to make requests to the Polygon API.
|
|
/// </summary>
|
|
private HttpClient _client;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="PolygonClient"/> class with the specified API key.
|
|
/// </summary>
|
|
/// <param name="apiKey">Polygon API key.</param>
|
|
public PolygonClient(string apiKey)
|
|
{
|
|
_client = new HttpClient { BaseAddress = new Uri("https://api.polygon.io") };
|
|
|
|
_client.DefaultRequestHeaders.Authorization =
|
|
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", apiKey);
|
|
}
|
|
|
|
private readonly JsonSerializerOptions _jsonOptions = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true,
|
|
};
|
|
}
|