Skip to main content

Revolution Next (*.revolutionnext.com.au) report downloads via REST API

Project description

revnext

Download Revolution Next (*.revolutionnext.com.au) reports (Parts Price List, Parts by Bin Location) via REST API. Uses auto-login and saves the session to disk so the next run reuses it; if the session is invalid, it logs in again automatically.

  • Install: pip install revnext
  • Editable (from repo root): pip install -e ./packages/revnext

Configuration (.env)

Put your base URL, username, and password in a .env file (e.g. in the project root or cwd). Optional: use python-dotenv so RevNextConfig.from_env() loads it.

Variable Required Description
REVNEXT_URL Yes Full base URL (e.g. https://yourtenant.revolutionnext.com.au)
REVNEXT_USERNAME Yes RevNext login User ID
REVNEXT_PASSWORD Yes RevNext login Password
REVNEXT_SESSION_PATH No Where to save/load session cookies (default: .revnext-session.json in cwd)

Example .env:

REVNEXT_URL=https://yourtenant.revolutionnext.com.au
REVNEXT_USERNAME=your_user_id
REVNEXT_PASSWORD=your_password

The first run logs in via the web form (CSRF + j_spring_security_check) and saves the session to REVNEXT_SESSION_PATH or .revnext-session.json. Later runs load that file, check that the session is still valid, and only re-login if it has expired.

Quick start

from pathlib import Path
from revnext import download_parts_by_bin_report, download_parts_price_list_report

# Config from env (.env or REVNEXT_*)
path1 = download_parts_by_bin_report(
    output_path=Path("C:/Reports/parts_by_bin.csv"),
)
path2 = download_parts_price_list_report(
    output_path=Path("C:/Reports/parts_price_list.csv"),
)

Return data in memory (e.g. for pandas)

Use return_data=True to get the CSV content as bytes without saving a file. Load into pandas with io.BytesIO:

import io
import pandas as pd
from revnext import download_parts_by_bin_report, download_parts_price_list_report

# Get report as bytes, then load into a DataFrame
csv_bytes = download_parts_by_bin_report(return_data=True)
df = pd.read_csv(io.BytesIO(csv_bytes))

# Or save to file yourself later
# Path("reports/parts_by_bin.csv").write_bytes(csv_bytes)

When return_data=True, the function returns bytes; when return_data=False (default), it saves to output_path and returns the Path.

Download one report with explicit config

from pathlib import Path
from revnext import RevNextConfig, download_parts_by_bin_report, download_parts_price_list_report

config = RevNextConfig.from_env()  # or RevNextConfig( base_url="...", username="...", password="...", session_path=... )

path1 = download_parts_by_bin_report(
    config=config,
    output_path=Path("C:/Reports/parts_by_bin.csv"),
)
path2 = download_parts_price_list_report(
    config=config,
    output_path=Path("C:/Reports/parts_price_list.csv"),
)

Example: download both reports (implement in your project)

from pathlib import Path
from typing import Optional

from revnext import RevNextConfig, download_parts_by_bin_report, download_parts_price_list_report


def download_all_reports(
    config: Optional[RevNextConfig] = None,
    output_dir: Optional[Path | str] = None,
) -> list[Path]:
    """Run both reports and save CSVs. Returns the list of paths where files were saved."""
    config = config or RevNextConfig.from_env()
    output_dir = Path(output_dir) if output_dir is not None else Path.cwd()
    path1 = download_parts_by_bin_report(
        config=config,
        output_path=output_dir / "Parts_By_Bin_Location.csv",
    )
    path2 = download_parts_price_list_report(
        config=config,
        output_path=output_dir / "Parts_Price_List.csv",
    )
    return [path1, path2]

Example: download both reports in parallel

from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import Optional

from revnext import RevNextConfig, download_parts_by_bin_report, download_parts_price_list_report


def download_all_reports_parallel(
    config: Optional[RevNextConfig] = None,
    output_dir: Optional[Path | str] = None,
) -> list[Path]:
    """Run both reports in parallel. Returns the list of paths where files were saved."""
    config = config or RevNextConfig.from_env()
    output_dir = Path(output_dir) if output_dir is not None else Path.cwd()
    path1 = output_dir / "Parts_By_Bin_Location.csv"
    path2 = output_dir / "Parts_Price_List.csv"
    with ThreadPoolExecutor(max_workers=2) as executor:
        f1 = executor.submit(
            download_parts_by_bin_report,
            config=config,
            output_path=path1,
        )
        f2 = executor.submit(
            download_parts_price_list_report,
            config=config,
            output_path=path2,
        )
        return [f1.result(), f2.result()]

See the main repo README for the monorepo layout.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

revnext-0.1.4.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revnext-0.1.4-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file revnext-0.1.4.tar.gz.

File metadata

  • Download URL: revnext-0.1.4.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for revnext-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6a7caa5a23f15feaef69ee0bee432ebed64adedf719d50d70a91217f5b95ac70
MD5 9ea316bfa43e518f5234b27bdf142d76
BLAKE2b-256 65beecc6618216d8cad25ede7e9e4d70d7dd510e10bbde5d2258c1aa7095de07

See more details on using hashes here.

File details

Details for the file revnext-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: revnext-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for revnext-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 af4810828592b7ff20456917a173c0601d2591ee6ca385c4e9fd73a712000e12
MD5 320dfb9b00d1c3d587bf1d182ae4d7ad
BLAKE2b-256 c0b969447ee31ef9ffbc00bc6299b2fdd2c661477029816685b742801e7a24d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page