Hammock

0.2.4 · abandoned · verified Sat Apr 11

Hammock is a lightweight Python library designed to provide a Pythonic interface for interacting with REST APIs. The current version is 0.2.4. Based on its last commit and release in 2017, the library is no longer actively maintained and appears to be abandoned, likely developed primarily for Python 2.

Warnings

Install

Imports

Quickstart

Demonstrates initializing Hammock and performing a basic GET request against the GitHub API to fetch user details. The response data is accessible via dot notation.

import os
from hammock import Hammock

# Hammock provides a Pythonic way to interact with REST APIs.
# For this public GitHub API endpoint, no authentication is strictly needed.
# For APIs requiring auth, you would typically pass headers or auth parameters
# during Hammock initialization or within specific HTTP method calls.
# For example: auth_token = os.environ.get("GITHUB_TOKEN", "")

github = Hammock("https://api.github.com")

# Perform a GET request to retrieve information about the 'octocat' user.
# Hammock allows chaining attributes for URL segments (e.g., .users('octocat')).
user_data = github.users('octocat').GET()

# The response data can be accessed like attributes or dictionary keys.
print(f"Octocat's name: {user_data.name}")
print(f"Octocat's public repositories: {user_data.public_repos}")
print(f"Octocat's followers: {user_data.followers}")

view raw JSON →