# 🇹🇷 Creart TDK Dictionary API - Advanced Node.js Module [](https://www.npmjs.com/package/creart-tdk) [](https://opensource.org/licenses/MIT) [](https://nodejs.org) [](https://www.npmjs.com/package/creart-tdk) [](https://github.com/hamzadenizyilmaz/Creart-TDK-Dictionary-API)        **Advanced Node.js module for accessing Turkish Language Institution (TDK) official dictionary data with advanced features like wildcard search, spell checking, daily word, and more!** ## ✨ **New in v1.4.0** ### 🚀 **New Features Added** - ✅ **Asterisk/Wildcard Search** - Advanced pattern matching - ✅ **Spell Checking** - Real-time Turkish spell checking with suggestions - ✅ **Daily Word** - Get word of the day with meaning - ✅ **Proverbs & Idioms** - Separate proverb/idiom search functionality - ✅ **Similar Words** - Find semantically similar words - ✅ **Letter-based Search** - Find words by starting letter - ✅ **Popular Searches** - Get most searched words - ✅ **Random Word** - Discover random Turkish words - ✅ **Pronunciation** - Word pronunciation and audio support - ✅ **Caching System** - Performance optimization with cache - ✅ **Rate Limiting** - API protection - ✅ **Batch Operations** - Multiple word search - ✅ **Health Check** - System monitoring - ✅ **Advanced Error Handling** - Better error messages - ✅ **API Server** - Built-in Express.js server ## 📦 **Installation** ```bash npm install creart-tdk # or yarn add creart-tdk ``` ## 🚀 **Quick Start** ### **Basic Usage** ```javascript const TDKSozluk = require('creart-tdk'); // Create instance const tdk = new TDKSozluk(); // Search word const result = await tdk.ara('merhaba'); console.log(result.data.kelime); // "merhaba" console.log(result.data.anlamlar); // Meanings array ``` ### **Asterisk Search (NEW!)** ```javascript // Wildcard search: "k?tap" finds words like "kitap", "katap" const wildcardResult = await tdk.asteriskAra('k?tap'); // Multiple unknowns: "k???p" finds 5-letter words const multiResult = await tdk.asteriskAra('k???p'); // Length specific: "k*p,5" finds 5-letter k...p words const lengthResult = await tdk.asteriskAra('k*p,5'); ``` ### **Spell Checking (NEW!)** ```javascript const spellCheck = await tdk.yazimDenetimi('Türkçe yazım öreneği'); console.log(spellCheck.data.istatistik.dogrulukOrani); // 75% console.log(spellCheck.data.sonuclar[3].oneriler); // ["örneği", "örnek", "ören"] ``` ## 📖 **Complete Usage Examples** ### **1. Full Feature Usage** ```javascript const TDKSozluk = require('creart-tdk'); const tdk = new TDKSozluk({ cache: true, timeout: 15000 }); // Word search with all features const wordResult = await tdk.ara('kitap', { telaffuz: true, // Include pronunciation cacheTTL: 3600 // Cache for 1 hour }); // Get today's word const dailyWord = await tdk.gununKelimesi(); // Spell check const spellCheck = await tdk.yazimDenetimi('Merhaba dünya!'); // Find proverbs const proverbs = await tdk.atasozuAra('ağaç'); // Find similar words const similar = await tdk.benzerKelimeler('sevgi', 5); // Find words by letter const letterWords = await tdk.harfeGoreKelimeler('a', 1, 10); // Get popular searches const popular = await tdk.populerAramalar(10); // Get random word const random = await tdk.rastgeleKelime(); // Get pronunciation const pronunciation = await tdk.sesGetir('merhaba'); ``` ### **2. API Server Usage** ```javascript const { createServer } = require('creart-tdk'); // Start API server createServer({ port: 3000, apiPath: '/api/v1', corsOrigin: 'https://yourdomain.com', rateLimitMax: 100, tdk: { cache: true, timeout: 20000 } }); ``` ## 🌐 **API Endpoints** When running as a server, these endpoints are available: | Method | Endpoint | Description | |--------|----------|-------------| | `GET` | `/api/kelime/:kelime` | Word search with details | | `GET` | `/api/asterisk/:pattern` | **NEW!** Asterisk pattern search | | `GET` | `/api/gunun-kelimesi` | Word of the day | | `POST` | `/api/yazim-denetimi` | Spell checking | | `GET` | `/api/atasozu/:anahtar` | Proverbs and idioms | | `GET` | `/api/benzer/:kelime` | Similar words | | `GET` | `/api/harf/:harf` | Words by letter | | `GET` | `/api/populer` | Popular searches | | `GET` | `/api/rastgele` | Random word | | `GET` | `/api/ses/:kelime` | Pronunciation | | `POST` | `/api/batch` | Batch word search | | `GET` | `/api/health` | Health check | | `GET` | `/api/cache/stats` | Cache statistics | | `DELETE` | `/api/cache` | Clear cache | ## 🔧 **Advanced Configuration** ### **Class Options** ```javascript const tdk = new TDKSozluk({ baseURL: 'https://sozluk.gov.tr/', timeout: 15000, // Request timeout retryCount: 3, // Retry attempts cache: true, // Enable caching // ... other options }); ``` ### **Search Options** ```javascript const result = await tdk.ara('kelime', { telaffuz: true, // Include pronunciation cacheTTL: 1800, // Cache time in seconds // Advanced options... }); ``` ## 🎯 **Asterisk Search Patterns** ### **Pattern Examples:** ``` k?tap → Matches: "kitap", "katap", "kutap" k???p → Matches 5-letter words: "kalıp", "künyep" a*a → Matches: "ada", "araba", "aşkla" k*p,5 → Matches 5-letter words: "kalıp", "kavup" ?e?me → Matches: "gelme", "değme", "seçme" ``` ### **Pattern Rules:** - `?` - Any single character - `*` - Any number of characters (including zero) - `,` - Length specifier (e.g., `,5` for 5 letters) - Case insensitive - Turkish character support ## 📊 **Response Structure** ### **Word Search Response:** ```javascript { success: true, data: { kelime: "merhaba", temelBilgiler: { madde: "merhaba", lisan: "Arapça", ozel_mi: false, cogul_mu: false }, anlamlar: [ { sira: 1, anlam: "Selam vermek, selamlaşmak", ornekler: ["Merhaba arkadaş!"], kullanim: "ünlem" } ], ornekler: [...], atasozleri: [...], deyimler: [...], birlesikler: [...], etimoloji: { /* etymology */ }, telaffuz: "mer-ha-ba", sesDosyasi: "https://.../merhaba.mp3", kullanimTuru: ["ünlem", "isim"], metadata: { islemSuresi: "450ms", veriKaynaklari: 5, tamVeri: true } }, metadata: { source: "TDK Sözlük", version: "1.4.0", timestamp: "2024-01-15T10:30:00.000Z" } } ``` ### **Spell Check Response:** ```javascript { success: true, data: { metin: "Türkçe yazım öreneği", sonuclar: [ { kelime: "Türkçe", dogru: true, oneriler: [] }, { kelime: "yazım", dogru: true, oneriler: [] }, { kelime: "denetimi", dogru: true, oneriler: [] }, { kelime: "öreneği", dogru: false, oneriler: ["örneği", "örnek", "ören"] } ], istatistik: { toplamKelime: 4, dogruKelime: 3, hataliKelime: 1, dogrulukOrani: "75.00" } } } ``` ## 🛡 **Error Handling** ```javascript try { const result = await tdk.ara('gecersizkelime123'); if (!result.success) { console.error('Hata:', result.error.message); console.error('Detay:', result.error.details); console.error('Kod:', result.error.code); } } catch (error) { console.error('Beklenmeyen hata:', error); } ``` ## ⚡ **Performance Features** ### **Caching System** - Automatic response caching - Configurable TTL - Cache statistics - Manual cache clearing ### **Rate Limiting** - Built-in rate limiting - Customizable limits - Fair usage protection ### **Batch Operations** ```javascript const batchResult = await fetch('/api/batch', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ kelimeler: ['merhaba', 'teşekkür', 'sevgi', 'aşk'] }) }); ``` ## 🚀 **Running as API Server** ### **Start Server:** ```bash # Direct execution node index.js # Using npm script npm start # With custom port PORT=8080 node index.js ``` ### **Docker Support:** ```dockerfile FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD ["node", "index.js"] ``` ## 🧪 **Testing** ### **Run Tests:** ```bash # Basic tests node test.js # With server tests node test.js --server # Performance tests node test.js --performance ``` ### **Test Examples:** ```javascript const test = require('./test'); await test.runAllTests(); await test.runPerformanceTest(); await test.runServerTest(); ``` ## 🔧 **Development** ### **Requirements:** - Node.js >= 14.0.0 - npm or yarn ### **Setup Development:** ```bash git clone https://github.com/hamzadenizyilmaz/Creart-TDK-Dictionary-API.git cd Creart-TDK-Dictionary-API npm install # Create word database node -e "const tdk = require('./index'); new tdk();" # Run development server npm run dev ``` ### **Build for Production:** ```bash npm run build npm test npm publish ``` ## 🤝 **Contributing** We welcome contributions! Here's how: 1. **Fork** the repository 2. **Create** feature branch: `git checkout -b feature/amazing-feature` 3. **Commit** changes: `git commit -m 'Add amazing feature'` 4. **Push** to branch: `git push origin feature/amazing-feature` 5. **Open** Pull Request ### **Contribution Guidelines:** - Follow existing code style - Add tests for new features - Update documentation - Ensure backward compatibility ## 📊 **Statistics** - **Word Database**: ~10,000+ Turkish words - **Response Time**: < 500ms average - **Cache Hit Rate**: > 60% with caching - **API Success Rate**: > 98% - **Memory Usage**: < 50MB typical ## ⚠️ **Important Notes** - **Not Official**: This is not an official TDK API - **Rate Limits**: Respect TDK servers, use caching - **Data Accuracy**: Data comes directly from TDK - **Updates**: Word database updates automatically - **License**: MIT - Free for commercial use ## 📞 **Support & Community** - **GitHub Issues**: [Bug Reports & Feature Requests](https://github.com/hamzadenizyilmaz/Creart-TDK-Dictionary-API/issues) - **Email**: info@hamzadenizyilmaz.com - **Website**: [https://hamzadenizyilmaz.com](https://hamzadenizyilmaz.com) - **Documentation**: [Full API Docs](https://github.com/hamzadenizyilmaz/Creart-TDK-Dictionary-API/wiki) ## 🔄 **Changelog** ### **v1.4.0** (Latest) - ✅ **Asterisk/Wildcard Search** - Advanced pattern matching - ✅ **Spell Checking System** - Turkish spell checker - ✅ **Daily Word Feature** - Word of the day - ✅ **Proverb Search** - Separate proverb/idiom search - ✅ **Similar Words** - Semantic similarity - ✅ **Letter Search** - Words by starting letter - ✅ **Popular Searches** - Most searched words - ✅ **Random Word** - Random Turkish word - ✅ **Pronunciation** - Audio pronunciation - ✅ **Cache Management** - Enhanced caching - ✅ **Rate Limiting** - API protection - ✅ **Batch Operations** - Multiple word search - ✅ **Health Monitoring** - System health check ### v1.3.0 - ✅ Complete rewrite with class-based architecture - ✅ Advanced error handling and recovery - ✅ Retry mechanism with exponential backoff - ✅ Detailed logging system - ✅ Multi-language support (English/Turkish) - ✅ Optional response caching - ✅ Comprehensive documentation - ✅ Improved performance with parallel requests - ✅ Enhanced TypeScript support - ✅ Better test coverage ### v1.0.0 - ✅ Added response caching - ✅ Improved error messages - ✅ Additional configuration options - ✅ Enhanced documentation ## 📄 **License** MIT License - see [LICENSE](LICENSE) file for details. ## 🙏 **Acknowledgments** - **TDK (Türk Dil Kurumu)** - For the dictionary data - **R10 Community** - For feature suggestions - **Contributors** - Everyone who helped improve this project ---