{"id":49199757,"url":"https://github.com/suradet-ps/thai-nlem-api","last_synced_at":"2026-05-27T11:38:00.811Z","repository":{"id":313508832,"uuid":"1051664837","full_name":"suradet-ps/thai-nlem-api","owner":"suradet-ps","description":"A simple REST API for searching and retrieving drug information from Thailand's National List of Essential Medicines (NLEM).","archived":false,"fork":false,"pushed_at":"2026-04-15T14:41:50.000Z","size":85,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-21T15:49:51.774Z","etag":null,"topics":["api","backend","healthcare","pharmacy","rest-api","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suradet-ps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-06T13:24:47.000Z","updated_at":"2025-10-06T13:32:46.000Z","dependencies_parsed_at":"2025-09-06T15:27:25.399Z","dependency_job_id":"00532dbc-a27a-4c95-9073-595e8ad2bb2b","html_url":"https://github.com/suradet-ps/thai-nlem-api","commit_stats":null,"previous_names":["pharmacist-sabot/thai-nlem-api","suradet-ps/thai-nlem-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/suradet-ps/thai-nlem-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suradet-ps%2Fthai-nlem-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suradet-ps%2Fthai-nlem-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suradet-ps%2Fthai-nlem-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suradet-ps%2Fthai-nlem-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suradet-ps","download_url":"https://codeload.github.com/suradet-ps/thai-nlem-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suradet-ps%2Fthai-nlem-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32181449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T11:42:27.955Z","status":"ssl_error","status_checked_at":"2026-04-23T11:42:18.877Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","backend","healthcare","pharmacy","rest-api","rust"],"created_at":"2026-04-23T13:06:02.031Z","updated_at":"2026-04-23T13:06:02.858Z","avatar_url":"https://github.com/suradet-ps.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thai NLEM API\n\n![Rust Version](https://img.shields.io/badge/rust-1.77%2B-orange.svg)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![Build Status](https://img.shields.io/github/actions/workflow/status/your-username/thai-nlem-api/rust.yml?branch=main) \u003c!-- TODO: Replace with your actual username/repo --\u003e\n\nAn open-source, unofficial REST API for accessing drug information from Thailand's National List of Essential Medicines (NLEM). Built with Rust, Axum, and SQLx for performance, safety, and reliability.\n\nThe goal of this project is to provide a clean, accessible, and well-documented API for developers, researchers, and healthcare professionals who need programmatic access to Thailand's essential medicine data.\n\n## ✨ Features\n\n-   **Fast \u0026 Efficient:** Built on the high-performance Axum web framework in Rust.\n-   **Type-Safe:** Leverages SQLx for compile-time checked SQL queries.\n-   **Search Functionality:** Powerful search endpoint for finding drugs by generic or synonym names.\n-   **Structured Data:** Provides drug information, including dosage forms, ED level, warnings, and conditions in a clean JSON format.\n-   **Open Source:** Free to use, modify, and contribute to under the MIT License.\n\n## 🚀 Getting Started\n\nFollow these instructions to get a local copy of the project up and running for development and testing purposes.\n\n### Prerequisites\n\n-   **Rust Toolchain:** Install from [rustup.rs](https://rustup.rs/).\n-   **PostgreSQL:** A running PostgreSQL instance. We recommend using [Docker](https://www.docker.com/products/docker-desktop/).\n-   **`sqlx-cli`:** For database migrations. Install with `cargo install sqlx-cli`.\n-   **Source Data:** The project requires the `nlem_2567.csv` data file. (Please provide source/link if available).\n\n### Installation \u0026 Setup\n\n1.  **Clone the repository:**\n    ```bash\n    git clone https://github.com/your-username/thai-nlem-api.git\n    cd thai-nlem-api\n    ```\n    \u003c!-- TODO: Replace with your actual username/repo --\u003e\n\n2.  **Setup the Database:**\n    -   If using Docker, start a PostgreSQL container:\n        ```bash\n        docker run --name nlem-db -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mypassword -e POSTGRES_DB=nlem_api_db -p 5432:5432 -d postgres:16-alpine\n        ```\n    -   Create a `.env` file from the example. Copy the content of `.env.example` (or create it manually).\n        ```bash\n        cp .env.example .env\n        ```\n    -   Update your `.env` file with your database connection string:\n        ```env\n        DATABASE_URL=\"postgres://myuser:mypassword@localhost:5432/nlem_api_db\"\n        ```\n\n3.  **Run Database Migrations:**\n    This command will create the necessary tables (`drugs`, `drug_categories`) in your database.\n    ```bash\n    sqlx database create # Only needed the first time\n    sqlx migrate run\n    ```\n\n4.  **Seed the Database:**\n    Place the `nlem_2567.csv` file inside the `data/` directory. Then, run the seeder to populate the database. This might take a few minutes.\n    ```bash\n    cargo run -- seed\n    ```\n\n5.  **Run the API Server:**\n    Once seeding is complete, you can start the API server.\n    ```bash\n    cargo run\n    ```\n    The server will be running at `http://localhost:3000`.\n\n## 📖 API Usage\n\nThe API provides several endpoints to access the drug data.\n\n### Health Check\n\n-   **Endpoint:** `GET /`\n-   **Description:** Checks if the API server is running.\n-   **Response:**\n    ```json\n    {\n      \"status\": \"OK\"\n    }\n    ```\n\n### Search for Drugs\n\n-   **Endpoint:** `GET /api/drugs/search`\n-   **Query Parameter:** `q` (string, required) - The search term.\n-   **Description:** Searches for drugs where the generic name or synonym name matches the query (case-insensitive).\n-   **Example:** `GET /api/drugs/search?q=paracetamol`\n-   **Response:** An array of drug objects.\n    ```json\n    [\n      {\n        \"id\": 1,\n        \"category_id\": 123,\n        \"generic_name\": \"Paracetamol\",\n        \"syn_name\": \"Acetaminophen\",\n        \"detail\": null,\n        \"drug_type\": null,\n        \"dosage_forms\": [\"tab\", \"syr\"],\n        \"ed_level\": \"ก\",\n        \"recommendations\": \"แนะนำให้ใช้เป็น first-line drug สำหรับ osteoarthritis\",\n        \"conditions\": null,\n        \"warnings\": null,\n        \"notes\": null,\n        \"footnote\": null,\n        \"source_code\": \"S\"\n      }\n    ]\n    ```\n\n### Get Drug by ID\n\n-   **Endpoint:** `GET /api/drugs/:id`\n-   **Path Parameter:** `id` (integer, required) - The unique ID of the drug.\n-   **Description:** Retrieves a single drug by its ID.\n-   **Example:** `GET /api/drugs/1`\n-   **Response:** A single drug object or a `404 Not Found` error.\n\n## 🤝 Contributing\n\nContributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1.  **Fork the Project**\n2.  **Create your Feature Branch** (`git checkout -b feature/AmazingFeature`)\n3.  **Commit your Changes** (`git commit -m 'Add some AmazingFeature'`)\n4.  **Push to the Branch** (`git push origin feature/AmazingFeature`)\n5.  **Open a Pull Request**\n\nPlease make sure to update tests as appropriate and ensure the code is formatted with `cargo fmt`.\n\n## 📜 License\n\nDistributed under the MIT License. See `LICENSE` file for more information.\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuradet-ps%2Fthai-nlem-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuradet-ps%2Fthai-nlem-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuradet-ps%2Fthai-nlem-api/lists"}