Skip to main content

CI PyPI

cragpy

A modern Python wrapper for the theCrag Logbook API.

Installation

Install dependencies locally or install the package in editable mode:

# Clone the repository
git clone https://github.com/coderiot/pycrag.git
cd pycrag

# Install package with test/development dependencies
pip install -e ".[test]"

Updating cragpy

# Update the package
pip install --upgrade cragpy

Usage

from cragpy import TheCragClient

# Initialize client
client = TheCragClient(api_key="YOUR-API-KEY")

# Fetch logbook ascents
# Optional parameters:
# - page: int
# - since: int 
logbook = client.get_logbook(page=1)

# Read account metadata
if logbook.account:
    print(f"Climber Profile: {logbook.account.name} (@{logbook.account.login})")
    print(f"Total Ascents: {logbook.account.ascentCount}")
    print(f"Cumulative Height Climbed: {logbook.account.heightClimbed}m")

# Loop through ascents
for ascent in logbook.ascents:
    print(f"Ascent ID: {ascent.id}")
    print(f"Logged Date: {ascent.logDate}")
    print(f"Route Name: {ascent.route.name if ascent.route else 'N/A'}")
    print(f"Grade: {ascent.route.grade if ascent.route else 'N/A'}")
    print(f"Tick style: {ascent.tick.name if ascent.tick else 'N/A'}")
    print("-" * 20)

Rate-Limiting & Retries

Customizing the requests-per-second limit

client = TheCragClient(api_key="YOUR-API-KEY", requests_per_second=1.0)

CLI Usage

Use the cragpy CLI tool to fetch your complete logbook.

# Export logbook to JSON file
cragpy --api-key YOUR-API-KEY --output my_logbook.json

# or using environment variable for API key
export THECRAG_API_KEY="YOUR-API-KEY"
cragpy -o my_logbook.json

# Output prints to stdout formatted in JSON.
cragpy --api-key YOUR-API-KEY

# Incremental Updates: Fetch only ascents after a specific epoch timestamp
cragpy --api-key YOUR-API-KEY --since 1700000000

# Export logbook in CSV format instead of JSON
cragpy --api-key YOUR-API-KEY --format csv -o my_logbook.csv

Running with uv

With uv you can use the CLI without installing the package first:

# Run directly from PyPI without installing (via uvx)
uvx cragpy --api-key YOUR-API-KEY -o my_logbook.json

# Or install it as a persistent tool on your PATH
uv tool install cragpy
cragpy --api-key YOUR-API-KEY -o my_logbook.json

Inside a clone of this repository, uv run sets up the environment and runs the CLI in one step:

uv run cragpy --api-key YOUR-API-KEY -o my_logbook.json

Running Tests & Formatting

Run the test suite using pytest:

pytest

Run code quality check and formatters using ruff:

ruff check
ruff format

Metadata

Release files for cragpy 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 cragpy 0.2.0
File Size Uploaded Provenance Actions
cragpy-0.2.0.tar.gz 9.5 kB With provenance Details for cragpy-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 17.3 kB

Release files / cragpy-0.2.0.tar.gz

Download URL cragpy-0.2.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
25d6b109f20b7ed2001626e565d2af268114257d34e8d2bc06656ee6615650e7
BLAKE2b-256 checksum
How to use checksums
9ad6beaac42ab6a229adeb197fbdfa7b4a2abd05a1d6014818275681d43ba50d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 17, 2026.

Transparency log

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

Download URL cragpy-0.2.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
188a2b94d5a43b63e16e7c44a448a0ab46294958e91dfc6702709204be6d9b09
BLAKE2b-256 checksum
How to use checksums
bd8c4e1cc5cc217fec7b675d5bd2c9f63d85f5a55e7655342b91775ec1225610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 17, 2026.

Transparency log

Security for cragpy 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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cragpy-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 Jul 17, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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