A PHP + Slim Framework API for personal library management system.
- Book Collection Status - Get total books, pages, keywords, and visits
- Book Details - Retrieve detailed book information by book ID
- Smart Caching - 24-hour TTL for static data, real-time for dynamic data
- API Key Authentication - Secure access control
- Apache Integration - Ready for production deployment
Visit the root URL (/) to access the interactive API documentation with detailed endpoint specifications, request/response examples, and data models.
GET /api/v1/books/status
Returns total books, pages, keywords, and visits count.
GET /api/v1/books/{bookid}
Returns detailed book information including:
- Basic book data (title, author, ISBN, etc.)
- Publisher and place names
- Tags and reviews
- Cover image URI
- Visit statistics (real-time)
All endpoints (except /health and /) require API key authentication via:
- Header:
X-API-Key: your-api-key - Query parameter:
?api_key=your-api-key
-
Clone the repository
git clone https://github.com/taylorren/api.rsywx.2025.git cd api.rsywx.2025 -
Install dependencies
composer install
-
Configure environment
cp .env.example .env # Edit .env with your database credentials and API key -
Set up Apache virtual host
sudo cp apache-vhost.conf /etc/apache2/sites-available/api.conf sudo a2ensite api.conf sudo a2enmod rewrite headers expires deflate sudo systemctl restart apache2
-
Set cache permissions
mkdir -p cache sudo chown -R www-data:www-data cache/
DB_HOST- Database hostDB_NAME- Database nameDB_USER- Database usernameDB_PASSWORD- Database passwordAPI_KEY- Your secure API key
The API works with the existing RSYWX database schema including:
book_book- Main books tablebook_publisher- Publishersbook_place- Storage locationsbook_taglist- Book tagsbook_review- Book reviewsbook_visit- Visit tracking
The API implements intelligent caching:
- Static data (book details, tags, reviews) cached for 24 hours
- Dynamic data (visit counts, last visited) always fresh
- Manual refresh available with
?refresh=trueparameter - File-based cache stored in
/cachedirectory
- API key authentication required
- CORS headers configured
- Security headers (X-Frame-Options, X-Content-Type-Options, etc.)
- Input validation and sanitization
- Error handling without information disclosure
curl http://your-domain/health# Collection status
curl -H "X-API-Key: your-key" http://your-domain/api/v1/books/status
# Book details
curl -H "X-API-Key: your-key" http://your-domain/api/v1/books/00666MIT License
Taylor Ren - Personal Library Management System