🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

github.com/jvcosta-dev/go-currency-exchange

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/jvcosta-dev/go-currency-exchange

Source
Go Modules
Version
v0.0.0-20241107182118-8e8e0bc3f81a
Version published
Created
Source

GO Currency Exchange

This project uses Go to serve currency data from over 160 different countries, using the public Exchange Rate API while minimizing the number of requests made through efficient routines.

Table of Contents

  • Project Info
  • Running the Application
  • Examples

Project Info

  • GO: 1.22.2

Running the Application

First get your API_KEY on https://app.exchangerate-api.com/dashboard Now create your .env.local file in internal/config dir and setup your API_KEY

Now run the main application

go run cmd/web/main.go

Examples

Convert Currency

Covert one currency to another and return its value

  • Request: GET

  • Endpoint: convert/{from}/{to}/{amount}

  • Path Params: from: "BRL", to: "USD", amount: 1

  • Response Example

{
  "from": "BRL",
  "to": "USD",
  "amount": 1,
  "result": 0.172,
  "rate": 5.8055,
  "last_update": "Tue, 05 Nov 2024 00:00:01 +0000"
}

Get Rate from Currency

Return currency rate based on USD

  • Request: GET

  • Endpoint: rate/{base}

  • Path Params: base: "BRL"

  • Response Example

{
  "base": "BRL",
  "rate": 5.8055,
  "last_update": "Tue, 05 Nov 2024 00:00:01 +0000"
}

Get All Rates

Return all currency rates based on USD

  • Request: GET

  • Endpoint: rates

  • Response Example

{
  "rates": {
    "AED": 3.6725,
    "AFN": 66.873,
    "ALL": 90.4668,
    "AMD": 387.0439,
    "ANG": 1.79,
    "AOA": 920.9918,
    "ARS": 993.33,
    "AUD": 1.5177,
    "AWG": 1.79,
    "AZN": 1.6993,
    "BAM": 1.7972,
    "BBD": 2,
    "BDT": 119.4957,
    "BGN": 1.7968,
    "BHD": 0.376,
    "BIF": 2910.6207,
    "BMD": 1,
    "BND": 1.3187,
    "BOB": 6.9214,
    "BRL": 5.8055,
    [...]
}

FAQs

Package last updated on 07 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts