Skip to main content

A Jupyter kernel for running Hurl commands

Project description

Jupyter Hurl Kernel

A Jupyter kernel for executing Hurl commands directly in Jupyter notebooks.

What is Hurl?

Hurl is a command line tool that runs HTTP requests defined in a simple plain text format. It's designed for testing HTTP endpoints, APIs, and web services. Learn more at hurl.dev.

Features

  • Execute Hurl commands directly in Jupyter notebook cells
  • Get HTTP responses displayed in the notebook
  • Supports all Hurl syntax and features
  • Easy to install and use

Prerequisites

  1. Python 3.13+ - This project requires Python 3.13 or higher
  2. Hurl - Install Hurl from hurl.dev/docs/installation.html

Installing Hurl

On macOS:

brew install hurl

On Linux:

# Debian/Ubuntu
curl -LO https://github.com/Orange-OpenSource/hurl/releases/latest/download/hurl_amd64.deb
sudo dpkg -i hurl_amd64.deb

# Or build from source
cargo install hurl

On Windows:

# Using Scoop
scoop install hurl

# Or using Chocolatey
choco install hurl

Verify the installation:

hurl --version

Installation

From PyPI (Recommended)

pip install jupyter-hurl-kernel
install-hurl-kernel

For installation in a virtual environment or server:

pip install jupyter-hurl-kernel
install-hurl-kernel --sys-prefix

That's it! The package includes syntax highlighting for both:

  • JupyterLab 4.x (automatic via bundled extension)
  • JupyterLab 3.x and Classic Jupyter Notebook (automatic via CodeMirror 5 mode)

From Source

  1. Clone or download this repository:
git clone https://github.com/micedre/jupyter-hurl-kernel.git
cd jupyter-hurl-kernel
  1. Install the package using uv:
uv pip install -e .
  1. Install the Jupyter kernel:
install-hurl-kernel

For installation in a virtual environment:

install-hurl-kernel --sys-prefix
  1. Verify the kernel is installed:
jupyter kernelspec list

You should see hurl in the list of available kernels.

Usage

  1. Start Jupyter Notebook or JupyterLab:
jupyter notebook
# or
jupyter lab
  1. Create a new notebook and select "Hurl" as the kernel

  2. Write Hurl commands in notebook cells:

Example 1: Simple GET request

GET https://www.insee.fr

Example 2: GET with headers

GET https://api.github.com/users/octocat
User-Agent: MyApp/1.0
Accept: application/json

Example 3: POST request

POST https://httpbin.org/post
Content-Type: application/json
{
  "name": "John Doe",
  "age": 30
}

Example 4: Testing with assertions

GET https://httpbin.org/json
HTTP 200
[Asserts]
jsonpath "$.slideshow.title" == "Sample Slide Show"

Example 5: Include response headers (using %%include)

%%include
GET https://api.github.com/users/octocat

Example 6: Verbose output with all details (using %%verbose)

%%verbose
GET https://api.github.com/users/octocat
  1. Run the cell (Shift+Enter) to execute the Hurl command

The kernel will display:

  • HTTP response output
  • Any errors or validation failures

Magic Lines

You can control the output level using magic lines at the start of cells. These magic lines correspond to Hurl's command-line flags:

  • No magic line (default) - Shows only the response body
  • %%include - Shows response headers and body (equivalent to hurl --include)
  • %%verbose - Shows all information including request details, response headers, body, timing, etc. (equivalent to hurl --verbose)

Examples:

Normal output (body only):

GET https://www.insee.fr

Include mode (headers + body):

%%include
GET https://www.insee.fr

Verbose mode (complete details):

%%verbose
GET https://www.insee.fr

Features

Autocompletion

The kernel provides intelligent autocompletion for Hurl syntax. Press Tab to trigger autocompletion:

  • HTTP Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, etc.
  • Common Headers: Content-Type:, Authorization:, Accept:, User-Agent:, etc.
  • Hurl Sections: [Asserts], [Captures], [QueryStringParams], [FormParams], etc.
  • Magic Lines: %%include, %%verbose
  • Content Types: When typing Content-Type:, get suggestions for common MIME types

The autocompletion is context-aware and will suggest relevant completions based on where your cursor is positioned.

Documentation Tooltips

Hover over or press Shift+Tab on keywords to see documentation:

  • HTTP Methods: See descriptions of what each HTTP method does
  • Hurl Sections: Get examples and explanations for each section type
  • Magic Lines: Learn what each magic line does

Example: Place your cursor on GET and press Shift+Tab to see:

HTTP GET Method

GET method requests a representation of the specified resource.
Requests using GET should only retrieve data.

Syntax Highlighting

The kernel includes built-in syntax highlighting for all Jupyter environments:

  • JupyterLab 4.x: Uses bundled CodeMirror 6 extension (automatically enabled)
  • JupyterLab 3.x and Classic Jupyter Notebook: Uses CodeMirror 5 mode (automatically enabled)

Syntax highlighting provides:

  • HTTP Methods (GET, POST, etc.) - highlighted as keywords
  • URLs - highlighted as strings
  • Headers - highlighted as attributes
  • Section headers ([Asserts], [Captures], etc.) - highlighted as headers
  • Magic lines (%%include, %%verbose) - highlighted as meta
  • Assertions (status, jsonpath, etc.) - highlighted as builtins
  • Operators (==, !=, >, <, etc.) - highlighted as operators
  • Numbers and strings - appropriately colored
  • Comments (#) - highlighted as comments
  • JSONPath and XPath expressions - highlighted as variables

The syntax highlighting is automatically installed when you run install-hurl-kernel. After installation, you may need to refresh your browser for the highlighting to take effect.

How It Works

The kernel works by:

  1. Taking the Hurl code from the notebook cell
  2. Writing it to a temporary .hurl file
  3. Executing hurl --color <file>
  4. Capturing and displaying the output in the notebook
  5. Cleaning up the temporary file

Troubleshooting

Code completion or syntax highlighting not working

If autocompletion or syntax highlighting isn't working on your Jupyter server, see the detailed TROUBLESHOOTING.md guide.

Quick fixes:

  1. Clear browser cache and hard refresh (Ctrl+Shift+R)
  2. Restart Jupyter server completely
  3. Reinstall: pip install --upgrade --force-reinstall jupyter-hurl-kernel
  4. Verify extension is loaded: jupyter labextension list (should show jupyterlab-hurl-extension)
  5. Check browser console (F12) for JavaScript errors

"hurl is not installed" error

Make sure Hurl is installed and available in your PATH:

which hurl
hurl --version

Kernel not appearing in Jupyter

Try reinstalling the kernel:

install-hurl-kernel --user
jupyter kernelspec list

Command timeout

By default, commands timeout after 30 seconds. For long-running requests, this can be adjusted in the kernel code.

Development

To modify the kernel:

  1. Clone the repository:

    git clone https://github.com/micedre/jupyter-hurl-kernel.git
    cd jupyter-hurl-kernel
    
  2. Install in development mode:

    uv pip install -e .
    install-hurl-kernel --sys-prefix
    
  3. Make your changes to the kernel code in src/jupyter_hurl_kernel/

  4. Restart your Jupyter notebook kernel to test changes

Running Tests

# Build the package to verify
uv build

# Check the distribution
uv tool run twine check dist/*

Uninstallation

To remove the kernel:

jupyter kernelspec uninstall hurl

To uninstall the package:

uv pip uninstall jupyter-hurl-kernel

License

This project is open source and available under the MIT License.

Contributing

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

Resources

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

jupyter_hurl_kernel-0.0.11.tar.gz (174.4 kB view details)

Uploaded Source

Built Distribution

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

jupyter_hurl_kernel-0.0.11-py3-none-any.whl (184.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_hurl_kernel-0.0.11.tar.gz.

File metadata

  • Download URL: jupyter_hurl_kernel-0.0.11.tar.gz
  • Upload date:
  • Size: 174.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jupyter_hurl_kernel-0.0.11.tar.gz
Algorithm Hash digest
SHA256 df11a63a10e637f1740d0989dbd80c57938a09386e575e6c937b2735550cdbcf
MD5 44cf78702a5d2cc7cf50a9416e41d2af
BLAKE2b-256 52856e212d4ae3aa494a0bcab25a92d994f7bad25048e10276cf40406e511173

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_hurl_kernel-0.0.11.tar.gz:

Publisher: publish.yml on micedre/jupyter-hurl-kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupyter_hurl_kernel-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_hurl_kernel-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 bd3f30ed96bd364a56ce5ea977ec00ab371d243c9788a62303ab02fa0e14f063
MD5 2acb31c1fa5514b1170dc78975408dd5
BLAKE2b-256 af99882a1e17634f160eb3f2a0e36d3aa4bd8102e16288b2d90d1b9411a24b7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_hurl_kernel-0.0.11-py3-none-any.whl:

Publisher: publish.yml on micedre/jupyter-hurl-kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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