How to get live (spot) gold price using API in C#?

< Back to Blog

C# is a general-purpose, multi-paradigm programming language. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented, and component-oriented programming disciplines. This tutorial is a how to get live gold price using C# programming language.

Instructions

  1. Get a free API to use by signing up at Metalpriceapi.com and replace REPLACE_ME with your API key.
  2. Update base value to a currency or remove this query param.
  3. Update currencies value to a list of values or remove this query param. In the example below, you will get precious metal rates for gold, silver, palladium, and platinum.

For 2 and 3, you can find this documented at Offical Documentation

 

Fetch live gold price in C# using ReSharp

var client = new RestClient("https://api.metalpriceapi.com/v1/latest?api_key=REPLACE_ME&base=USD&currencies=XAU,XAG,EUR");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);