{"id":15111219,"url":"https://github.com/aiyu-ayaan/dictionary-ktor-server","last_synced_at":"2026-01-05T18:12:06.349Z","repository":{"id":256807783,"uuid":"856484027","full_name":"aiyu-ayaan/Dictionary-Ktor-Server","owner":"aiyu-ayaan","description":"Dictionary KMP is a Kotlin Multiplatform project that leverages Ktor Server to provide word definitions via a simple API. It fetches word meanings from an external dictionary API and handles requests efficiently with built-in timeout configurations.","archived":false,"fork":false,"pushed_at":"2024-09-12T17:34:50.000Z","size":68,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-31T09:12:42.034Z","etag":null,"topics":["kotlin","ktor-server"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aiyu-ayaan.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-12T16:46:25.000Z","updated_at":"2024-09-13T13:40:46.000Z","dependencies_parsed_at":"2024-09-13T06:18:35.436Z","dependency_job_id":null,"html_url":"https://github.com/aiyu-ayaan/Dictionary-Ktor-Server","commit_stats":null,"previous_names":["aiyu-ayaan/dictionary-ktor-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiyu-ayaan%2FDictionary-Ktor-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiyu-ayaan%2FDictionary-Ktor-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiyu-ayaan%2FDictionary-Ktor-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiyu-ayaan%2FDictionary-Ktor-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aiyu-ayaan","download_url":"https://codeload.github.com/aiyu-ayaan/Dictionary-Ktor-Server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222384031,"owners_count":16975396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","ktor-server"],"created_at":"2024-09-26T00:02:34.230Z","updated_at":"2026-01-05T18:12:06.300Z","avatar_url":"https://github.com/aiyu-ayaan.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dictionary-Ktor-Server\n\nA simple Dictionary API using Ktor Server and Kotlin Multiplatform Project (KMP). This project fetches word definitions\nfrom an external dictionary API.\n\n## Features\n\n- **Ktor Server** for handling requests.\n- **HTTP Client** to fetch word definitions from a third-party API.\n- **Timeouts** configured to handle network delays.\n\n## Prerequisites\n\n- [Kotlin](https://kotlinlang.org/) installed on your machine.\n- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/) with KMP support.\n- [Ktor](https://ktor.io/) for creating the server.\n\n## Getting Started\n\n### Clone the Repository\n\n```bash\ngit clone https://github.com/aiyu-ayaan/Dictionary-Ktor-Server\ncd Dictionary-Ktor-Server\n```\n\n### Setting Up the Ktor Server\n\n1. Open the project in IntelliJ IDEA.\n\n### Running the Application\n\n1. Use the following command to run your Ktor server:\n\n   ```bash\n   ./gradlew run\n   ```\n\n2. The server will be running on `http://localhost:9090/`.\n\n### API Endpoints\n\n#### Get Welcome Message\n\n```http\nGET /\n```\n\n**Response:**\n\n```json\n{\n  \"message\": \"Welcome to Dictionary API\"\n}\n```\n\n#### Get Word Definition\n\n```http\nGET /word/{word}\n```\n\n**Example Request:**\n\n```http\nGET /word/example\n```\n\n**Response:**\n\nReturns the JSON response from [Dictionary API](https://dictionaryapi.dev/).\n\n```json\n[\n   {\n      \"word\": \"example\",\n      \"phonetic\": \"/əɡˈzæmpl̩/\",\n      \"phonetics\": [\n         {\n            \"text\": \"/əɡˈzæmpl̩/\",\n            \"audio\": \"\"\n         },\n         {\n            \"text\": \"/ɘɡˈzɐːmpɯ/\",\n            \"audio\": \"\"\n         },\n         {\n            \"text\": \"/ɪɡˈzɑːmpl̩/\",\n            \"audio\": \"\"\n         },\n         {\n            \"text\": \"/əɡˈzæmpl̩/\",\n            \"audio\": \"https://api.dictionaryapi.dev/media/pronunciations/en/example-us.mp3\",\n            \"sourceUrl\": \"https://commons.wikimedia.org/w/index.php?curid=267013\"\n         }\n      ],\n      \"meanings\": [\n         {\n            \"partOfSpeech\": \"noun\",\n            \"definitions\": [\n               {\n                  \"definition\": \"Something that is representative of all such things in a group.\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               },\n               {\n                  \"definition\": \"Something that serves to illustrate or explain a rule.\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               },\n               {\n                  \"definition\": \"Something that serves as a pattern of behaviour to be imitated (a good example) or not to be imitated (a bad example).\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               },\n               {\n                  \"definition\": \"A person punished as a warning to others.\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               },\n               {\n                  \"definition\": \"A parallel or closely similar case, especially when serving as a precedent or model.\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               },\n               {\n                  \"definition\": \"An instance (as a problem to be solved) serving to illustrate the rule or precept or to act as an exercise in the application of the rule.\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               }\n            ],\n            \"synonyms\": [],\n            \"antonyms\": []\n         },\n         {\n            \"partOfSpeech\": \"verb\",\n            \"definitions\": [\n               {\n                  \"definition\": \"To be illustrated or exemplified (by).\",\n                  \"synonyms\": [],\n                  \"antonyms\": []\n               }\n            ],\n            \"synonyms\": [],\n            \"antonyms\": []\n         }\n      ],\n      \"license\": {\n         \"name\": \"CC BY-SA 3.0\",\n         \"url\": \"https://creativecommons.org/licenses/by-sa/3.0\"\n      },\n      \"sourceUrls\": [\n         \"https://en.wiktionary.org/wiki/example\"\n      ]\n   }\n]\n```\n\n### Error Handling\n\nIf an error occurs (e.g., invalid word or network issue), you'll get the following response:\n\n```json\n{\n  \"error\": \"An error occurred\"\n}\n```\n\n### Configuration\n\nYou can configure the timeouts in the `configureRouting` function:\n\n```kotlin\ninstall(HttpTimeout) {\n    requestTimeoutMillis = 30000 // 30 seconds\n    connectTimeoutMillis = 30000 // 30 seconds\n}\n```\n\n### Project Structure\n\n- `Application.kt`: Contains the routing logic and API integration.\n- `build.gradle.kts`: The Gradle configuration file.\n\n### Dictionary API\n\nThis project uses the [Dictionary API](https://dictionaryapi.dev/) to fetch word meanings.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.\n\n## GitHub\n\n[Dictionary KMP GitHub Repo](https://github.com/aiyu-ayaan/Dictionary-KMP)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiyu-ayaan%2Fdictionary-ktor-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiyu-ayaan%2Fdictionary-ktor-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiyu-ayaan%2Fdictionary-ktor-server/lists"}