Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


thttp is a single file, lightweight, well-tested wrapper around urllib that's intended to be copied directly into your project.

It's features include:

  • Making GET, POST, PATCH, PUT, HEAD and OPTIONS requests
  • Sending query parameters with your request
  • Encoding JSON payloads for POST, PATCH and PUT requests
  • Encoding form-encoded payloads for POST, PATCH and PUT request
  • Sending custom headers with any request
  • Disabling SSL certificate verification for local testing / corporate proxies
  • Following (or not following) redirects
  • Sending through a CookieJar object that can be reused between requests
  • Authenticating with HTTP basic auth
  • Specifying a custom timeout for your request
  • Decompressing gzipped content in the response
  • Loading JSON from the response
  • Returning error responses instead of throwing exceptions from urllib
  • pretty() function for printing responses

Future features:

  • Better detection of JSON responses
  • Improve handling of non-utf-8 requests
  • Improve handling of non-utf-8 responses

Note: this project is not intended to solve all use cases that can be achieved with urllib, requests or other HTTP libraries. The intent is to provide a lightweight tool that simplifies some of the most common use cases for developers.


copy directly into your project:

curl >

Or, install with pip:

python3 -m pip install thttp

Basic Usage

See the tests for examples of usage, but, effectively it's as simple as:

from thttp import request

response = request("", params={"data": "empty"})

# {'args': {'data': ['empty']}, 'headers': {'Accept-Encoding': ['identity'], 'Fly-Client-Ip': [''], 'Fly-Forwarded-Port': ['443'], 'Fly-Forwarded-Proto': ['https'], 'Fly-Forwarded-Ssl': ['on'], 'Fly-Region': ['hkg'], 'Fly-Request-Id': ['01F6P2WQAY1NGPRDCXV9H60XW5'], 'Host': [''], 'User-Agent': ['Python-urllib/3.8'], 'Via': ['1.1'], 'X-Forwarded-For': [','], 'X-Forwarded-Port': ['443'], 'X-Forwarded-Proto': ['https'], 'X-Forwarded-Ssl': ['on'], 'X-Request-Start': ['t=1622091390302198']}, 'origin': ',', 'url': ''}

# 200

Running the tests

> python3 -m unittest

And to check the coverage:

> coverage run -m unittest
> coverage html && open htmlcov/index.html

Run black before committing any changes.

> black

Packaging for release

rm dist/*
python3 -m build
python3 -m twine upload dist/*