Files
NostrServices/NostrServices.Client/NostrServicesClient.cs
2024-01-13 20:07:27 +00:00

36 lines
853 B
C#

using Newtonsoft.Json;
namespace NostrServices.Client;
public class NostrServicesClient
{
private readonly HttpClient _client;
public NostrServicesClient(HttpClient client)
{
_client = client;
_client.BaseAddress = new Uri("https://nostr.api.v0l.io");
}
public async Task<NostrProfile?> Profile(string id)
{
var rsp = await _client.GetAsync($"/api/v1/export/profile/{id}");
if (rsp.IsSuccessStatusCode)
{
var json = await rsp.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<NostrProfile>(json);
}
return default;
}
public class NostrProfile
{
[JsonProperty("name")]
public string? Name { get; init; }
[JsonProperty("lud16")]
public string? LightningAddress { get; init; }
}
}