Apotek Tools
A comprehensive CLI tool for interacting with the Apotek Aulia Farma API. This tool is designed to handle various API operations including fetching price lists, with plans to support additional functionality in the future.
Features
Current Features
- Fetch drug price list from Apotek Aulia Farma API
- Generate formatted Excel file with price information
Installation
Prerequisites
- Python 3.8 or higher
- uv - Fast, reliable Python package management
Setup
-
Install uv if you don't have it yet:
curl -LsSf https://astral.sh/uv/install.sh | sh
-
Clone the repository:
git clone https://github.com/yourusername/apotek-tools.git cd apotek-tools
-
Create a virtual environment and install the package:
uv venv source .venv/bin/activate # On Linux/macOS # or .\.venv\Scripts\activate # On Windows uv pip install -e .
Alternatively, use the provided setup script:
./setup_uv.sh
Setup with Makefile (easiest)
If you have make installed, you can use the Makefile for an easy setup:
make setup
Usage
The CLI is structured using command groups to organize functionality by area:
uv run apotek_tools [command-group] [command] [options]
Available Command Groups
pricelist: Commands for managing drug price listsauth: Commands for authentication managementconfig: Commands for managing application configuration
Available Commands
Global Commands
fetch: Shortcut forpricelist fetch(for backward compatibility)cookie: Shortcut forauth cookie(for backward compatibility)info: Display information about the API and tool
Price List Commands
uv run apotek_tools pricelist fetch [options]
This will:
- Fetch the drug list from the API
- Process the data
- Display a preview of the data
- Ask for confirmation to generate the Excel file
- Create an Excel file with price information
Options:
--cookie, -c: Cookie value to use for authentication (JSON format)--cookie-file: Path to cookie file (default: cookie.json)--output, -o: Output file path--preview/--no-preview: Preview the data before generating Excel (default: --preview)--preview-limit: Number of items to preview (default: 10)--config-file: Path to config file (default: apotek_config.json)
Authentication Commands
uv run apotek_tools auth cookie [options]
Options:
--set: Set cookie value--get: Get current cookie value--delete: Delete cookie file--file, -f: Cookie file path (default: cookie.json)
Configuration Commands
uv run apotek_tools config contact [options]
Options:
--whatsapp: Set WhatsApp contact number--email: Set email contact address--show: Show current contact info (default behavior if no options)--config-file: Path to config file (default: apotek_config.json)
Example:
# Update WhatsApp number
uv run apotek_tools config contact --whatsapp="+6281223556554"
# Update email
uv run apotek_tools config contact --email="new.email@auliafarma.co.id"
# Show current settings
uv run apotek_tools config contact --show
Running with make
You can use the Makefile to run commands easily:
# Run a command
make run fetch
# With options
make run fetch --no-preview
# Get help
make run --help
# Configure contact info
make run config contact --whatsapp="+6281223556554"
Getting Help
For general help:
uv run apotek_tools --help
For help with a command group:
uv run apotek_tools [command-group] --help
For help with a specific command:
uv run apotek_tools [command-group] [command] --help
Configuration
Contact Information
Contact information is stored in apotek_config.json and includes:
- WhatsApp number (default: +6281223556554)
- Email address (default: kontak@auliafarma.co.id)
This contact information is included in generated Excel files.
Cookie Format
The cookie file should be a JSON file with key-value pairs:
{
"cookie_name": "cookie_value",
"session_id": "your_session_id"
}
Excel Output Format
The generated Excel file for price lists will have the following format:
Daftar Harga Apotek Aulia Farma per [current date]
Kontak WhatsApp: +6281223556554
Email: kontak@auliafarma.co.id
Nama Obat | Harga Diskon | Sisa Stok
--------------------------------------
Drug 1 | Rp xxx | xx Pcs
Drug 2 | Rp xxx | xx Pcs
...
Development
For a comprehensive guide on using uv for development, see UV_DEVELOPMENT.md.
Project Structure
The codebase is structured to make it easy to add new functionality:
apotek_tools/api.py: Core API interaction module (use this for new API endpoints)apotek_tools/fetcher.py: Data processing for drug listsapotek_tools/excel_generator.py: Excel file generationapotek_tools/cli.py: Command-line interfaceapotek_tools/config.py: Configuration management
Adding New Commands
To add a new command to the CLI, extend the appropriate Click group in cli.py. For example:
# Add a command to an existing group
@pricelist.command("search")
@click.argument("query")
def search_drugs(query):
"""Search for drugs by name."""
# Implementation goes here
pass
# Create a new command group
@cli.group()
def inventory():
"""Commands for managing inventory."""
pass
# Add a command to the new group
@inventory.command("check")
@click.argument("drug_code")
def check_inventory(drug_code):
"""Check the inventory for a specific drug."""
# Implementation goes here
pass
Using uv for Development
uv provides several commands that make Python development faster:
# Create a virtual environment
uv venv
# Activate the virtual environment
source .venv/bin/activate # Linux/macOS
.\.venv\Scripts\activate # Windows
# Install dependencies from pyproject.toml
uv pip install -e .
# Install specific packages
uv pip install requests pandas
# Run a Python script directly (no need to activate venv)
uv run python path/to/script.py
# Run the CLI
uv run -m apotek_tools [command]
# Run pip commands with uv's speed improvements
uv pip list
uv pip freeze
Makefile Commands
The project includes a Makefile with useful commands for development:
make help # Show available commands
make setup # Set up development environment with uv
make venv # Create a virtual environment with uv
make install # Install the package in development mode using uv
make run [args] # Run the CLI with arguments using uv
make clean # Clean build artifacts
make test # Run tests using uv (when implemented)
License
MIT
Metadata
Release files for apotek-tools 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| apotek_tools-0.1.0.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apotek_tools-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / apotek_tools-0.1.0.tar.gz
| Download URL | apotek_tools-0.1.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a2946a457e5c06e849fd564925d6670bc7c7f2b1188cddc4744ffa58b8ecb15
|
|
BLAKE2b-256 checksum How to use checksums |
b551f1859819ecb19bee7626187b210d4f258fdea0d50cee90b4f9fae8ce7a38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 1, 2025.
Transparency logRelease files / apotek_tools-0.1.0-py3-none-any.whl
| Download URL | apotek_tools-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78fc1f5d3cff9010f2f205f92c46e094c24998531083983e250d69eb22d5abcf
|
|
BLAKE2b-256 checksum How to use checksums |
99e8b612e9685bc60593553beac91021d87bbcb04f50518f12ad62275da8164f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 1, 2025.
Transparency log