A RESTful API built with Go and PostgreSQL, designed to manage SWIFT codes for banks worldwide. The API provides functionality to retrieve, create, and delete SWIFT codes efficiently.
- Retrieve details of a single SWIFT code (including headquarters and branches).
- Get all SWIFT codes for a specific country.
- Create a new SWIFT code entry.
- Delete an existing SWIFT code.
- Fully containerized using Docker and Docker Compose.
sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl enable --now docker- Download and install Docker Desktop from here.
- Ensure Docker is running before proceeding.
git clone https://github.com/YourUsername/swift-api.git
cd swift-apiAdd the .env file to the swift-api folder.
Launch the terminal in the swift-api folder and enter the following command (works on both Windows and Linux):
docker-compose up --buildThis will build the Go application, start PostgreSQL and set up the environment variables.
After the containers start, check if the API is running:
curl http://localhost:8080/pingExpected response:
{"message": "pong"}To stop the containers without deleting data, press CTRL+C or run:
docker-compose downTo stop and remove all data (including the database):
docker-compose down -v| Method | Endpoint | Description |
|---|---|---|
| GET | /ping |
Health check |
| GET | /v1/swift-codes |
Get all SWIFT codes |
| GET | /v1/swift-codes/:swift-code |
Get details of a specific SWIFT code |
| GET | /v1/swift-codes/country/:countryISO2code |
Get SWIFT codes for a country |
| POST | /v1/swift-codes |
Create a new SWIFT code |
| DELETE | /v1/swift-codes/:swift-code |
Delete a SWIFT code |