How to Convert Exchange Rates Between Currencies using Go
Exchange rate conversion services are simply a must-have for most financial applications. To that end, our Exchange Rate Conversion API presents a free, easy-to-use solution which can be built into your applications with ready-to-run, complementary code examples. This API uses the latest available data to make your currency exchange rate conversion, and accepts three-letter country codes (e.g., USD, EUR, etc.) as the basis for the operation.
To take advantage of this API, simply copy the below examples (provided here in Go, but available here in several other common programming languages) into your environment, and then authenticate the service with a valid Cloudmersive API key (you can get one for free when you register a free account on our website):
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cloudmersive.com/currency/exchange-rates/get/%3Cstring%3E/to/%3Cstring%3E"
method := "POST"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}