98 lines
1.5 KiB
Markdown
98 lines
1.5 KiB
Markdown
# bpi-stock-price-scraper
|
|
|
|
Web server API to fetch latest BPI PPR stock prices on demand.
|
|
|
|
## Features
|
|
|
|
- REST API endpoints to get latest prices for BPI Destino PPR funds
|
|
- Returns price data as JSON
|
|
- Dockerized for easy deployment
|
|
- Health check endpoint included
|
|
|
|
## Available Symbols
|
|
|
|
- `BPIDEST2040` - BPI Destino PPR 2040
|
|
- `BPIDEST2050` - BPI Destino PPR 2050
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /` - API information and usage examples
|
|
- `GET /health` - Health check with available symbols
|
|
- `GET /price/:symbol` - Get latest price for a specific symbol
|
|
|
|
### Example Response
|
|
|
|
```json
|
|
{
|
|
"symbol": "BPIDEST2040",
|
|
"name": "BPI Destino PPR 2040",
|
|
"price": 7.73313,
|
|
"date": "2026-04-09",
|
|
"timestamp": "2026-04-10T16:11:25.850Z"
|
|
}
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Docker (Recommended)
|
|
|
|
Build and run with docker-compose:
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
Or build and run manually:
|
|
|
|
```bash
|
|
docker build -t bpi-stock-price-scraper .
|
|
docker run -p 3000:3000 bpi-stock-price-scraper
|
|
```
|
|
|
|
### Node.js
|
|
|
|
Install dependencies and run:
|
|
|
|
```bash
|
|
npm install
|
|
npm start
|
|
```
|
|
|
|
For development with auto-reload:
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The server runs on port 3000 by default. You can change it via the `PORT` environment variable:
|
|
|
|
```bash
|
|
PORT=8080 npm start
|
|
```
|
|
|
|
Or in docker-compose.yml:
|
|
|
|
```yaml
|
|
environment:
|
|
- PORT=8080
|
|
ports:
|
|
- "8080:8080"
|
|
```
|
|
|
|
## Testing
|
|
|
|
Test the API:
|
|
|
|
```bash
|
|
# Get API info
|
|
curl http://localhost:3000/
|
|
|
|
# Check health
|
|
curl http://localhost:3000/health
|
|
|
|
# Get latest price
|
|
curl http://localhost:3000/price/BPIDEST2040
|
|
```
|