Documentation
filetype-detector¶
Detect file types from paths, file signatures, or model-based analysis with one Python library and one consistent interface.
Start Here¶
-
Getting Started
Install the package, check system dependencies, and run the first successful detection.
-
Choose an Inferencer
Pick the right backend for trusted extensions, content validation, text precision, or mixed workloads.
-
Reference
Look up exact API behavior for AutoInferencer, BaseInferencer, and each concrete inferencer.
-
Explanation
Understand the trade-offs behind lexical, magic, magika, and hybrid detection.
Quick Start¶
Content-based backends require the supplied path to reference an existing file.
from filetype_detector import AutoInferencer
inferencer = AutoInferencer(backend="hybrid")
file_type = inferencer.infer("document.pdf")
'.pdf' in file_type.extensions # True
Quick Decision Guide¶
-
Need the fastest possible answer?
Start with
LexicalInferencer. -
Need content-based validation?
Start with
MagicInferencer. -
Need text precision or confidence scores?
Start with
MagikaInferencer. -
Need one strong default for mixed files?
Start with
AutoInferencer(backend="hybrid").
Common Tasks¶
-
Choose the right backend
-
Scan many files
-
Add project-specific detection
-
Reuse working snippets
Requirements¶
- Python >= 3.10
- python-magic >= 0.4.27 for MagicInferencer and HybridInferencer
- magika >= 1.0.1 for MagikaInferencer and HybridInferencer
- rich >= 14.2.0 and textual >= 8.2.8 for the terminal demo
See Getting Started for platform-specific system library installation instructions.