State Bank of Pakistan Exchange Rates
State Bank of Pakistan Exchange Rates
Overview
The State Bank of Pakistan (SBP) publishes exchange rates for various currencies against the Pakistani Rupee (PKR) on a daily basis. They publish the exchange rates on the internet in PDF format at a deterministic URL for each day. This library provides an interface to fetch and/or download the exchange rates for any given date.
Example Rate Sheets
:::caution[Important] These rates will almost always differ from google rates (e.g. rates from google search). :::
Installation
go get github.com/mistermoe/sbpfxQuick Start
package main
import ( "context" "fmt" "log"
"github.com/mistermoe/sbpfx")
func main() { client := sbpfx.New() rate, err := client.GetExchangeRate(context.Background(), sbpfx.USD) if err != nil { log.Fatalf("failed to get exchange rate: %v", err) }
fmt.Printf("USD to PKR: %s\n", rate.GetSpotRate())}Features
- π Current Exchange Rates: Get todayβs rates with no configuration
- π Historical Data: Fetch rates for any specific date
- πΎ PDF Download: Download original PDF rate sheets
- π URL Generation: Get direct links to rate sheet PDFs
- π Multiple Currencies: Support for USD, EUR, GBP, JPY, and 25+ other currencies
- β‘ Human-Friendly API: Use simple date strings like β2025-08-27β
- π§ͺ Well Tested: Comprehensive test suite with VCR for reliable testing
- π¦ Zero Dependencies: Minimal external dependencies for easy integration