My goal is basically to fetch my portfolio balance from a Crypto Exchange called Bitstamp. So far, I managed to use their public API (https://www.bitstamp.net/api/ticker/) and this works. The code I used for that is the following:
public class ConsoleApp4
{
static void Main()
{
RunAsync().Wait();
}
static async Task RunAsync()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://www.bitstamp.net/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//HTTP GET
HttpResponseMessage response = await client.GetAsync("api/ticker/");
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine ($"error: {response.StatusCode}");
}
Console.ReadLine();
}
}
}
However, I want to try to access this API : https://www.bitstamp.net/api/v2/balance/ This one requires authentication to be added and I have no idea as to how to go about it. This is the API guide that Bitstamp gives: https://www.bitstamp.net/api/ I'm trying to use the V2 authentication, which requires me to add an API key, a signature and a nonce.
I would already be helped a lot when someone can explain to me how to properly add the authentication headers and I would (hopefully) be able to figure out the rest.