Skip to content

Documentation

filetype-detector

Detect file types from paths, file signatures, or model-based analysis with one Python library and one consistent interface.

Hybrid by default Single `AutoInferencer` entry point Reference + guides + explanations

Start Here

  • Getting Started


    Install the package, check system dependencies, and run the first successful detection.

    Open the tutorial

  • Choose an Inferencer


    Pick the right backend for trusted extensions, content validation, text precision, or mixed workloads.

    Open the guide

  • Reference


    Look up exact API behavior for AutoInferencer, BaseInferencer, and each concrete inferencer.

    Open reference overview

  • Explanation


    Understand the trade-offs behind lexical, magic, magika, and hybrid detection.

    Open explanation overview

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

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.