A command-line tool and Python library for fetching Medium articles. This tool allows you to download articles from Medium using their URLs and save them as Markdown files for offline reading, archiving, or content repurposing.
- Download Medium articles by URL
- Save articles as Markdown format
- Support for batch processing multiple URLs
- Caching system to avoid redundant API calls
- Interactive mode for entering URLs
- Rich terminal output with progress indicators
- Python 3.13 or higher
- RapidAPI key for Medium API access (free tier: 150 requests/month)
- click >= 8.2.1 - Command line interface creation
- diskcache >= 5.6.3 - Disk-based cache implementation
- pydantic >= 2.11.7 - Data validation and settings management
- python-dotenv >= 1.1.1 - Environment variable management
- requests >= 2.32.4 - HTTP requests
- rich >= 14.0.0 - Rich text and formatting in the terminal
- pre-commit >= 4.2.0 - Git hook scripts
- pytest >= 8.4.1 - Testing framework
- ruff >= 0.12.4 - Fast Python linter and formatter
-
Python 3.13+: Ensure you have Python 3.13 or higher installed.
-
RapidAPI Key: Sign up at RapidAPI and subscribe to the Medium API to get your API key.
If you use mise for managing Python versions and dependencies:
# Clone the repository
git clone https://github.com/yourusername/medium-md-fetcher.git
cd medium-md-fetcher
# Install Python and dependencies with mise
mise use -g [email protected]
# Install project dependencies with uv
uv sync# Clone the repository
git clone https://github.com/yourusername/medium-md-fetcher.git
cd medium-md-fetcher
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root with your RapidAPI key:
RAPIDAPI_KEY=your_rapidapi_key_here
Alternatively, you can pass the API key directly using the --api-key option.
The tool provides a command-line interface for downloading Medium articles:
# Download articles from URLs
python medium.py download --urls https://medium.com/article1-url https://medium.com/article2-url
# Download articles from a file (one URL per line)
python medium.py download --file articles.txt
# Interactive mode
python medium.py download --interactive
# Specify output directory
python medium.py download --urls https://medium.com/article-url --articles-path custom/output/path--urls, -u: Medium URLs to download (can be used multiple times)--file, -f: File containing URLs (one per line)--interactive, -i: Interactive URL input--api-key: RapidAPI key (overrides environment variable)--cache-path: Cache database path (default: "data/cache")--articles-path: Saved articles path (default: "data/articles")--verbose, -v: Verbose output
You can also use the library programmatically in your Python code:
import os
from src.medium_api_client.client import MediumAPIClient
# Load API key from environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create client
client = MediumAPIClient(api_key=api_key)
# Get article by URL
article_url = "https://medium.com/@author/article-title-123abc"
article = client.get_article_by_url(article_url)
if article:
print(f"Title: {article.title}")
print(f"Author: {article.author}")# Clone the repository
git clone https://github.com/yourusername/medium-md-fetcher.git
cd medium-md-fetcher
# Install Python and dependencies with mise
mise use -g [email protected]
# Install development dependencies
uv pip syncThe project uses ruff for code formatting and linting:
# Format code
make format
# Lint code
make lint# Run all tests
pytest tests/MIT License. See the LICENSE file.
- Medium API on RapidAPI - API for accessing Medium content
- Put together with ❤️ by Aleš Lončar
Issues, feedback, and PRs are welcome. Fork and submit your ideas!
- Follow PEP 8 guidelines
- Use ruff for formatting and linting
- Write docstrings for all functions, classes, and modules
- Add type hints where appropriate
- Write tests for new features and bug fixes