Tools for Apotek price list management
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apotek_tools-0.1.0.tar.gz.
File metadata
- Download URL: apotek_tools-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a2946a457e5c06e849fd564925d6670bc7c7f2b1188cddc4744ffa58b8ecb15
|
|
| MD5 |
504d8900e08f099421fb3d5124e5a303
|
|
| BLAKE2b-256 |
b551f1859819ecb19bee7626187b210d4f258fdea0d50cee90b4f9fae8ce7a38
|
Provenance
The following attestation bundles were made for apotek_tools-0.1.0.tar.gz:
Publisher:
python-publish.yml on turfaa/apotek-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apotek_tools-0.1.0.tar.gz -
Subject digest:
3a2946a457e5c06e849fd564925d6670bc7c7f2b1188cddc4744ffa58b8ecb15 - Sigstore transparency entry: 190603834
- Sigstore integration time:
-
Permalink:
turfaa/apotek-tools@82a6a87bb7ad8fb5e1d414dfbadca837b70155ce -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/turfaa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@82a6a87bb7ad8fb5e1d414dfbadca837b70155ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file apotek_tools-0.1.0-py3-none-any.whl.
File metadata
- Download URL: apotek_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78fc1f5d3cff9010f2f205f92c46e094c24998531083983e250d69eb22d5abcf
|
|
| MD5 |
e79c5081db06adaa5a99267b73df4056
|
|
| BLAKE2b-256 |
99e8b612e9685bc60593553beac91021d87bbcb04f50518f12ad62275da8164f
|
Provenance
The following attestation bundles were made for apotek_tools-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on turfaa/apotek-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apotek_tools-0.1.0-py3-none-any.whl -
Subject digest:
78fc1f5d3cff9010f2f205f92c46e094c24998531083983e250d69eb22d5abcf - Sigstore transparency entry: 190603837
- Sigstore integration time:
-
Permalink:
turfaa/apotek-tools@82a6a87bb7ad8fb5e1d414dfbadca837b70155ce -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/turfaa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@82a6a87bb7ad8fb5e1d414dfbadca837b70155ce -
Trigger Event:
release
-
Statement type: