http requests with urllib3

Python
API
Published

October 27, 2024

My goal is to use the urllib3 more regularly. It is a library that has no dependencies (see below)

Here are some examples of making http requests with urllib3.

import urllib3

resp = urllib3.request(
  "GET",
  "https://doi.org/10.1177/1465116507076430",
  headers = {"accept": "application/vnd.citationstyles.csl+json"}
  )
resp.status
200
doi_json = resp.json()
doi_json['author']
[{'given': 'Holger',
  'family': 'Döring',
  'sequence': 'first',
  'affiliation': [{'name': 'Max Planck Institute for the Study of Societies, Germany,'}]}]
resp.data[:100]
b'{"indexed":{"date-parts":[[2025,7,8]],"date-time":"2025-07-08T00:11:55Z","timestamp":1751933515556,"'

Dependencies

urllib3 has no dependencies and the popular requests library uses urllib3.

Here is a documentation of the dependencies with uv.

uv init uv-project
cd uv-project

uv add urllib3
uv tree
Resolved 2 packages in 2ms
uv-project v0.1.0
└── urllib3 v2.2.3
uv remove urllib3
uv add requests
uv tree
Resolved 6 packages in 2ms
uv-project v0.1.0
└── requests v2.32.3
    ├── certifi v2024.8.30
    ├── charset-normalizer v3.4.0
    ├── idna v3.10
    └── urllib3 v2.2.3