January 8, 2026

#2 - Setting Up a Python API Testing Project with uv

api-testingpythonuv

Understanding uv and its key advantages

What is uv?

uv is an extremely fast, modern Python package and project manager written in Rust, designed as an all-in-one replacement for existing tools like pip, virtualenv, pipx, and pyenv. uv promises dramatic performance gains and a simplified workflow for Python developers.

It consolidates multiple tools into a single, cohesive command-line interface — pip + venv + pip-tools + pipx, replaced by one fast tool.

It fully supports pyproject.toml for defining project metadata and dependencies, aligning with modern Python packaging standards.

Advantages

  1. pyproject.toml as the source of truth
  2. A lockfile (uv.lock) for deterministic installs
  3. No need to "activate" a venv
  4. Better dev vs. prod dependency separation

Essential uv commands for project setup

Setup uv and python

Installation diagram

Install uv and update path:

curl -Ls https://astral.sh/uv/install.sh | bash

Verify uv is installed:

uv --version
uv 0.9.21

Install a Python version:

uv python install 3.14

List Python versions: uv python list

  • Lists all Python interpreters uv can see (includes system-installed and uv-installed Python).
  • uv separates system Python from project Python, so OS updates can't silently break your code or CI pipelines.
  • uv python list always shows system-installed Python if no Python is installed via uv, because uv discovers and reuses what the OS already provides.
  • Once you install Python via uv python install, uv prefers that version, but system Python remains visible as a fallback — not replaced.

Python versions list

Pin the project's Python version:

echo "3.13" > .python-version
cat .python-version

Initialize the project: uv init

Project initialization

Optionally update the project description in pyproject.toml:

Configuration update

Creating an API testing project using uv

Set up the virtual environment:

uv venv --python 3.13

Install packages:

uv add requests faker
uv add --group test pytest
uv add --dev black ruff mypy

After running the commands above, pyproject.toml is updated with the dependencies and uv.lock is created:

Updated pyproject.toml

Lock file creation

List dependencies: uv pip list

Dependency list

Reference

Originally published on Hashnode.