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:

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

For JupyterLab 4.x users: You also need to install the syntax highlighting extension:

jupyter labextension install jupyterlab-hurl-extension

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. (JupyterLab 4.x only) Install the syntax highlighting extension:
jupyter labextension install jupyterlab-hurl-extension
  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

Important: Syntax highlighting setup depends on your Jupyter environment:

  • JupyterLab 4.x: Requires installing a separate extension:
    jupyter labextension install jupyterlab-hurl-extension
    
  • JupyterLab 3.x or Classic Jupyter Notebook: Works automatically after running install-hurl-kernel

The kernel includes syntax highlighting support that 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. JupyterLab 4.x users: Install the extension from npm:
    jupyter labextension install jupyterlab-hurl-extension
    
  2. Clear browser cache and hard refresh (Ctrl+Shift+R)
  3. Restart Jupyter server
  4. Reinstall kernel: install-hurl-kernel --sys-prefix (for servers/virtual environments)
  5. If you don't want to install the extension, use classic Jupyter Notebook instead: jupyter notebook

"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.5.tar.gz (10.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.5-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jupyter_hurl_kernel-0.0.5.tar.gz
  • Upload date:
  • Size: 10.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.5.tar.gz
Algorithm Hash digest
SHA256 00508c20f69b0790fe276e434c1ff942cf203237d0b958e39d5a481266ed9d2b
MD5 cd9aefd7b4794614bd5aad3a8527f815
BLAKE2b-256 1295bb120decd0d342d71f60a45534cec9ecda0b70685092d429a03aa37e079d

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_hurl_kernel-0.0.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_hurl_kernel-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8f7ef3af0028bee3e1714aa3917c95efe6773ea118037875a8380f20f7034790
MD5 45532676f4a9d0eabe659c92acbbabcb
BLAKE2b-256 76f95a4ba81c917af0fe5a88224a7c7259d88f07d4fd362b1c57dce8a4f91a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyter_hurl_kernel-0.0.5-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