Skip to main content

kegger

Documentation PyPI Python Version License: MIT

Interact with the KEGG (Kyoto Encyclopedia of Genes and Genomes) API using Python and Pandas.

Retrieve genes, pathways, and associated data for organisms of interest in the KEGG database. Originally developed for RNA-seq analysis to organize gene expression patterns by KEGG pathways.

Features

  • 🧬 Retrieve pathway information for any organism in KEGG
  • 📊 Returns data as Pandas DataFrames for easy analysis
  • 🔍 Parse KEGG records into structured dictionaries
  • 💾 Built-in request caching for faster repeated queries
  • 🐍 Simple, intuitive Python API

Installation

Install from PyPI using pip:

pip install kegger

Or using uv:

uv add kegger

Quick Start

Get all pathways for an organism

import kegger as kg

org = "eco"  # E. coli K-12 MG1655
org_pathways = kg.list_all_pathways(org)

print(org_pathways.head())

Output:

     pathid                                        description
0  eco01100  Metabolic pathways - Escherichia coli K-12 MG1655
1  eco01110  Biosynthesis of secondary metabolites - Escher...
2  eco01120  Microbial metabolism in diverse environments -...
3  eco01200   Carbon metabolism - Escherichia coli K-12 MG1655
4  eco01210  2-Oxocarboxylic acid metabolism - Escherichia ...

Get all genes and their pathway associations

genes_pathids = kg.genes_to_pathways(org)
genes_pathids = genes_pathids.merge(org_pathways, how="outer")
print(genes_pathids.head())

Output

     pathid   gene                                        description
0  eco00010  b0114  Glycolysis / Gluconeogenesis - Escherichia col...
1  eco00010  b0115  Glycolysis / Gluconeogenesis - Escherichia col...
2  eco00010  b0116  Glycolysis / Gluconeogenesis - Escherichia col...
3  eco00010  b0325  Glycolysis / Gluconeogenesis - Escherichia col...
4  eco00010  b0356  Glycolysis / Gluconeogenesis - Escherichia col...

Get details for a specific pathway from a KEGG Entry

If you need more details about a pathway, use the get_path() function to retrieve the raw text from the KEGG request and kegg_parser() to convert the string into a dictionary.

pathid = "eco00190"  # Oxidative phosphorylation
path_record = kg.get_path(pathid) # the kegg request as a string
path_dict = kg.kegg_parser(path_record)

# Available data fields
print(path_dict.keys())
# dict_keys(['ENTRY', 'NAME', 'CLASS', 'PATHWAY_MAP', 'MODULE', 
#            'ORGANISM', 'GENE', 'ORTHOLOG', 'COMPOUND', 
#            'REFERENCE', 'AUTHORS', 'TITLE', 'JOURNAL', 'KO_PATHWAY'])

# Show the pathway name
print(path_dict.get("NAME"))
# Oxidative phosphorylation - Escherichia coli K-12 MG1655

# Show associated modules
print(path_dict.get("MODULE"))
# [
# 'eco_M00144  NADH:quinone oxidoreductase, prokaryotes [PATH:eco00190]',
# 'eco_M00149  Succinate dehydrogenase, prokaryotes [PATH:eco00190]',
# 'eco_M00150  Fumarate reductase, prokaryotes [PATH:eco00190]',
# 'eco_M00153  Cytochrome bd ubiquinol oxidase [PATH:eco00190]',
# 'eco_M00157  F-type ATPase, prokaryotes and chloroplasts [PATH:eco00190]', 
# 'eco_M00417  Cytochrome o ubiquinol oxidase [PATH:eco00190]'
# ]

# Get genes in this pathway
genes = path_dict.get("GENE")
print(f"Found {len(genes)} genes in pathway")
print(genes[:5])  # First 5 genes
# ['b0428', 'b0429', 'b0430', 'b0431', 'b0432']

Get annotation and KEGG pathways for all genes

import kegger as kg

org = "eco"
annotated_org = kg.get_org(org)
genes_pathways_org = annotated_org.merge(org_pathways, how="outer")
print()

Documentation

Full documentation is available at https://csaltikov.github.io/kegger/

Requirements

  • Python ≥ 3.13
  • pandas ≥ 2.2.3
  • requests ≥ 2.32.5
  • requests-cache ≥ 1.2.1

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use kegger in your research, please cite:

Saltikov, C. (2025). kegger: A Python package for interacting with the KEGG API. 
GitHub repository: https://github.com/csaltikov/kegger

Acknowledgments

This package interfaces with the KEGG API. Please cite KEGG appropriately in your work:

Kanehisa, M. and Goto, S.; KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res. 28, 27-30 (2000).

Metadata

Release files for kegger 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kegger 0.2.0
File Size Uploaded Provenance Actions
kegger-0.2.0.tar.gz 89.4 kB With provenance Details for kegger-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kegger 0.2.0
File Interpreter ABI Platform Actions
kegger-0.2.0-py3-none-any.whl Python 3 none any Details for kegger-0.2.0-py3-none-any.whl

Total release size: 100.3 kB

Release files / kegger-0.2.0.tar.gz

Download URL kegger-0.2.0.tar.gz
Size 89.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1cf1d1957243993a3e73583241736164cf4799d7dd80b13a1661fd13cad7a656
BLAKE2b-256 checksum
How to use checksums
fae596652ebdf66f283dafad5fdccea7af2591da4bbf5e7fdef156018aba2002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

Release files / kegger-0.2.0-py3-none-any.whl

Download URL kegger-0.2.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9578075df1cef0737504975c44f1a8c41e2cd2e9f7ac206724927ee287ea8623
BLAKE2b-256 checksum
How to use checksums
ee618df6354bb571706deef94fd3bcc7f8e7ade3d4e5145ae16799a3ed116aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

Security for kegger 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kegger-0.2.0.tar.gz

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 Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page