This is the backend API that powers molexa.org. I built it because the PubChem API has CORS restrictions and lacks educational context that students need. Instead of just proxying requests, I enhanced it with autocomplete suggestions, safety information, and educational explanations.
When building the moleXa frontend, I needed a reliable way to fetch molecular data from PubChem without running into CORS issues. But more importantly, I wanted to add educational value - things like explaining what molecular properties mean, providing safety warnings, and offering smart search suggestions. The result is an API that's specifically designed for chemistry education.
- CORS-enabled PubChem proxy - Access any PubChem endpoint from web applications
- Educational enhancements - Contextual explanations for molecular properties
- Smart autocomplete - Chemical name suggestions as you type
- Safety information - Toxicity data and handling procedures
- Analytics tracking - Usage statistics for educational impact
- Caching system - Fast responses with intelligent cache management
- Rate limiting - Respects PubChem's 5 requests/second limit
# Clone the repo
git clone https://github.com/bazarkua/molexa-api.git
cd molexa-api
# Install dependencies
npm install
# Set up environment variables (optional)
cp .env.example .env
# Start development server
npm run dev
# Test the API
curl http://localhost:3001/api/healthGet comprehensive data with educational context:
GET /api/pubchem/compound/{name}/educational?type=name
Chemical name suggestions:
GET /api/autocomplete/{query}?limit=5
Toxicity and handling data:
GET /api/pugview/compound/{cid}/safety?heading=Toxicity
Direct access to any PubChem endpoint:
GET /api/pubchem/compound/name/aspirin/cids/JSON
GET /api/pubchem/compound/cid/2244/PNG
Search for caffeine and get educational data:
curl "https://molexa-api.vercel.app/api/pubchem/compound/caffeine/educational?type=name"Get autocomplete suggestions:
curl "https://molexa-api.vercel.app/api/autocomplete/caffe?limit=5"Fetch safety information for aspirin:
curl "https://molexa-api.vercel.app/api/pugview/compound/2244/safety?heading=Toxicity"# Optional - for analytics storage
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_key
# Optional - for admin features
ADMIN_TOKEN=your_admin_token
# Optional - for data privacy
HASH_SALT=your_hash_saltThe API is deployed on Vercel and automatically builds from the main branch. It's configured to work as a serverless function with proper caching and rate limiting.
# Deploy to Vercel
vercel --prod
# Or use the GitHub integration for automatic deploymentsThe API tracks educational usage patterns to understand how students and educators use molecular data. All tracking is privacy-focused with hashed IP addresses and focuses on educational impact metrics.
View live analytics at: https://molexa-api.vercel.app/api/docs
# Start with hot reloading
npm run dev
# Run tests
npm test
# Check API health
npm run validate- Interactive docs: https://molexa-api.vercel.app/api/docs
- JSON specification: https://molexa-api.vercel.app/api/json/docs
- Live analytics: https://molexa-api.vercel.app/api/analytics
- Node.js & Express - Core server framework
- Vercel - Serverless deployment platform
- Supabase - Analytics database (optional)
- node-cache - In-memory caching
- express-rate-limit - API rate limiting
I welcome contributions, especially from educators who know what students need. Feel free to open issues for feature requests or submit PRs for improvements.
This project was developed with invaluable assistance from Claude AI by Anthropic.
If you use this API in research or educational materials, please cite:
Bazarkulov, A. (2025). moleXa API: PubChem Educational Proxy API (Version 2.2.0) [Computer software].
GitHub. https://github.com/bazarkua/molexa-api
And don't forget to cite PubChem:
Kim, S., Chen, J., Cheng, T., et al. (2025). PubChem 2025 update.
Nucleic Acids Research, 53(D1), D1516–D1525. https://doi.org/10.1093/nar/gkae1059
MIT License - see LICENSE for details.
- Live API: https://molexa-api.vercel.app
- Frontend: https://molexa.org
- Frontend repo: https://github.com/bazarkua/molexa
- PubChem: https://pubchem.ncbi.nlm.nih.gov
Built with passion and vision for accessible education.
