https://github.com/bitebait/dolarpy-go
Go package to easily consume the Dolarpy API.
https://github.com/bitebait/dolarpy-go
api api-wrapper currency dollar exchange-rate finance golang guarani paraguay
Last synced: 3 months ago
JSON representation
Go package to easily consume the Dolarpy API.
- Host: GitHub
- URL: https://github.com/bitebait/dolarpy-go
- Owner: bitebait
- License: mit
- Created: 2021-11-30T17:52:46.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-25T02:09:45.000Z (over 2 years ago)
- Last Synced: 2024-06-20T19:21:04.973Z (almost 2 years ago)
- Topics: api, api-wrapper, currency, dollar, exchange-rate, finance, golang, guarani, paraguay
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dolarpy-go
Go Package to easily consume the [Dolarpy API](https://dolar.melizeche.com).
- by [melizeche](https://github.com/melizeche/)
## Install
```go
go get github.com/bitebait/dolarpy-go
```
## Usage Example
```go
package main
import (
"encoding/json"
"fmt"
"github.com/bitebait/dolarpy-go"
)
func main() {
allData, err := dolarpy.All()
if err != nil {
fmt.Printf("Failed to get all providers data: %v\n", err)
return
}
fmt.Println(allData)
providers, err := dolarpy.Providers()
if err != nil {
fmt.Printf("Failed to get providers names: %v\n", err)
return
}
fmt.Println(providers)
reference, err := dolarpy.Reference()
if err != nil {
fmt.Printf("Failed to get reference value: %v\n", err)
return
}
fmt.Println(reference)
purchase, err := dolarpy.Purchase("cambioschaco")
if err != nil {
fmt.Printf("Failed to get purchase value from 'cambioschaco': %v\n", err)
return
}
fmt.Println(purchase)
sale, err := dolarpy.Sale("cambioschaco")
if err != nil {
fmt.Printf("Failed to get sale value from 'cambioschaco': %v\n", err)
return
}
fmt.Println(sale)
data, err := dolarpy.All()
if err != nil {
fmt.Printf("Failed to get all providers data: %v\n", err)
return
}
j, _ := json.Marshal(data)
fmt.Println(string(j))
for provider, values := range data {
purchase := values["compra"]
sale := values["venta"]
fmt.Printf("Provider: %s - [Purchase: %.2f Sale: %.2f]\n", provider, purchase, sale)
}
}
```
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## License
This project is licensed under the terms of the MIT License - see the [LICENSE](LICENSE) file for details