A Node.js service that parses PhonePe transaction history text files and converts them into structured JSON data.
PhonePe emails a password protected PDF on demand. Needed to convert it to json for my expense tracking app, so here's a service that does that.
- Parses PhonePe transaction history text files
- Extracts detailed transaction information including timestamps, amounts, and transaction IDs
- Returns structured JSON data
- Includes request logging and error handling
- Production-ready with proper logging setup
- Node.js (v14 or higher)
- pnpm
- Clone the repository
- Install dependencies:
pnpm install- Start the server:
pnpm startThe server will start on port 3000 by default (configurable via PORT environment variable).
- Send a POST request to
/processendpoint with a text file:
curl -X POST -F "file=@your-transactions.txt" http://localhost:3000/processThe API returns JSON in the following format:
{
"success": true,
"count": number,
"transactions": [
{
"ts": "ISO timestamp",
"payee": "string",
"txn_id": "string",
"utr_no": "string",
"payer": "string",
"kind": "string",
"currency": "string",
"amount": number
}
],
"meta": {
"file_type": "string",
"original_name": "string",
"processing_time_ms": number
}
}PORT: Server port (default: 3000)NODE_ENV: Environment setting ('development' or 'production')
This project uses the following open-source packages:
- Express - Fast, unopinionated web framework for Node.js
- Multer - Middleware for handling multipart/form-data
- date-fns - Modern JavaScript date utility library
- Morgan - HTTP request logger middleware
- Gist by @vsbabu - Python script that converts phonepe txn to psv
MIT
Contributions are welcome! Please feel free to submit a Pull Request.