An open API service indexing awesome lists of open source software.

https://github.com/gozeloglu/currency-tcmb

TCMB(Central Bank of the Republic of Türkiye) currency API written in Go.
https://github.com/gozeloglu/currency-tcmb

api currency go golang tcmb tcmb-api

Last synced: 4 days ago
JSON representation

TCMB(Central Bank of the Republic of Türkiye) currency API written in Go.

Awesome Lists containing this project

README

          

# currency-tcmb

`currency-tcmb` is a Go API for the Central Bank of the Republic of Türkiye(TCMB) currency data. It fetches the data from the [URL](https://www.tcmb.gov.tr/kurlar/today.xml),
parses the XML, and returns necessary information. It returns today's data.

## Installation

```shell
go get github.com/gozeloglu/currency-tcmb
```

## Usage

```go
func main() {
tcmb := currency.New() // It fetches and parses the XML data in background
usdCurrency := tcmb.FromCurrencyCode(currency.USD) // Get USD currency against TRY
fmt.Println(usdCurrency.BanknoteBuying())
fmt.Println(usdCurrency.BanknoteSelling())
}
```

You can retrieve the historical currency by passing `WithDate()` option.

```go
tcmb := currency.New(WithDate(1, time.September, 2021)) // It fetches 01 September 2021 currency data.
```

## LICENSE
[MIT](LICENSE)