Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MiguelNavas19/miapibcv/llms.txt

Use this file to discover all available pages before exploring further.

This guide will help you get Mi API BCV running locally in just a few minutes.

Prerequisites

Before you begin, ensure you have the following installed:
The default configuration uses SQLite for simplicity. You can switch to MySQL or PostgreSQL later if needed.

Installation

1

Clone the repository

git clone https://github.com/yourusername/mi-api-bcv.git
cd mi-api-bcv
2

Install dependencies

composer install
This will install Laravel 12 and all required packages including:
  • Symfony DomCrawler for web scraping
  • Laravel Sanctum for API authentication (optional)
3

Set up environment

cp .env.example .env
php artisan key:generate
The .env file is now configured with sensible defaults using SQLite.
4

Create the database

touch database/database.sqlite
If you prefer MySQL or PostgreSQL, update the DB_CONNECTION and related variables in your .env file before running migrations.
5

Run migrations

php artisan migrate
This creates the necessary database tables:
  • reference_records - Stores exchange rate data
  • cache - Stores cached API responses
  • jobs - Handles queue jobs if needed
6

Fetch initial exchange rates

php artisan rates:update
This command scrapes the current exchange rates from all banks and stores them in the database.Expected output:
Iniciando actualización de tasas...
Banco bdv procesado.
Banco banplus procesado.
Banco bnc procesado.
Banco bcv procesado.
Tasas actualizadas exitosamente.
7

Start the development server

php artisan serve
The API is now running at http://localhost:8000

Test Your Installation

Get all current rates

curl http://localhost:8000/
Expected response:
{
  "message": "Consulta exitosa",
  "bdv": {
    "value": 45.26,
    "date": "2026-03-04"
  },
  "banplus": {
    "value": 45.30,
    "date": "2026-03-04"
  },
  "bnc": {
    "value": 45.28,
    "date": "2026-03-04"
  },
  "bcv": {
    "value": 45.25,
    "date": "2026-03-04"
  }
}

Get rates for a specific date and bank

curl http://localhost:8000/info/2026-03-04/bcv
Response:
{
  "message": "Consulta exitosa",
  "bcv": {
    "value": 45.25,
    "date": "2026-03-04"
  }
}

Set Up Automatic Updates

To keep exchange rates updated automatically, set up the Laravel scheduler:
Edit your crontab:
crontab -e
Add this line:
* * * * * cd /path/to/mi-api-bcv && php artisan schedule:run >> /dev/null 2>&1
The scheduler is configured to run the rates:update command 11 times daily at specific hours (00:00, 00:30, 02:00, 03:00, 03:30, 04:00, 05:00, 05:30, 06:30, 07:00, 07:30) when bank websites typically update their rates.

API Endpoints

The API provides two main endpoints:

GET /

Returns current exchange rates from all banks for today. Parameters: None Response: JSON object with rates from all sources

GET /info/{date}/{source?}

Returns exchange rates for a specific date, optionally filtered by bank. Parameters:
  • date (required) - Date in YYYY-MM-DD format
  • source (optional) - Bank identifier: bcv, banplus, bnc, or bdv
Examples:
# All banks for a specific date
curl http://localhost:8000/info/2026-03-04

# Specific bank and date
curl http://localhost:8000/info/2026-03-04/bcv

Next Steps

How It Works

Learn about the scraping architecture

Configuration

Customize environment variables

Deployment

Deploy to production

Data Sources

Understand the bank data sources

Troubleshooting

This means no exchange rates have been fetched yet. Run:
php artisan rates:update
Some banks may temporarily block requests or change their website structure. Check the logs:
tail -f storage/logs/laravel.log
The system is designed to continue working even if one bank fails.
Ensure your cache configuration is correct in .env:
CACHE_STORE=database
Clear the cache if needed:
php artisan cache:clear

Build docs developers (and LLMs) love