Overview
Create an examples/ directory demonstrating the hypothesisapi library capabilities. Use a hybrid approach:
- Read-only examples: Use public fixture annotations on Wikipedia
- Write examples: Self-contained create/update/delete cycles
Why Wikipedia for Fixtures
- Sustainability: Stable, long-lived platform
- Versioned URLs: Permanent revision links (
oldid=...) for testing anchor stability
- Content drift testing: Demonstrates real-world annotation behavior when underlying content changes
- Educational: Meta-relevant content (annotating articles about annotation)
Phase 1: Create Fixture Annotations
Target page: Web annotation
URL Variants to Annotate
Fixture Annotations to Create
All tagged #hypothesisapi-example for easy discovery:
Phase 2: Write Examples
Basic Operations (Read-only, use fixtures)
Creating and Managing Annotations (Self-contained)
Bulk Operations
Groups
Profile and Discovery
Phase 3: Documentation
Implementation Notes
Authentication Pattern
# Examples should support both env var and 1Password
import os
api_key = os.environ.get("HYPOTHESIS_API_KEY")
if not api_key:
print("Set HYPOTHESIS_API_KEY or run with: op run --env HYPOTHESIS_API_KEY='op://...' -- python example.py")
Fixture Discovery
# Examples can find fixtures by tag
FIXTURE_TAG = "hypothesisapi-example"
fixtures = list(api.search(tag=FIXTURE_TAG, limit=20))
Self-Contained Pattern
# Create → use → cleanup pattern
annotation = api.create({"uri": "...", "text": "temporary test"})
try:
# ... demo operations ...
finally:
if input("Delete test annotation? [y/N] ").lower() == 'y':
api.delete(annotation["id"])
Acceptance Criteria
Overview
Create an
examples/directory demonstrating the hypothesisapi library capabilities. Use a hybrid approach:Why Wikipedia for Fixtures
oldid=...) for testing anchor stabilityPhase 1: Create Fixture Annotations
Target page: Web annotation
URL Variants to Annotate
https://en.wikipedia.org/wiki/Web_annotationhttps://en.wikipedia.org/w/index.php?title=Web_annotation&oldid=XXXXXXX(get current revision ID)Fixture Annotations to Create
All tagged
#hypothesisapi-examplefor easy discovery:#hypothesisapi-example,#test-fixture,#web-annotationPhase 2: Write Examples
Basic Operations (Read-only, use fixtures)
01_read_annotation.py- Fetch and display a single annotation by ID02_collection_stats.py- Get statistics about your annotation collection03_search_by_uri.py- Find all annotations on a specific webpage04_search_by_tag.py- Find annotations by tag (demo with#hypothesisapi-example)Creating and Managing Annotations (Self-contained)
05_create_annotation.py- Create annotation → display → offer to delete06_update_annotation.py- Create → update text/tags → display diff → cleanup07_delete_annotation.py- Create temporary annotation → delete with confirmationBulk Operations
08_export_annotations.py- Export to JSON/CSV (runs on user's own data)09_bulk_tag_update.py- Self-contained: create several → bulk update tags → cleanupGroups
10_list_groups.py- List groups with details (read-only)11_create_private_group.py- Create group → display → offer to delete12_group_annotations.py- Search annotations in a specific groupProfile and Discovery
13_profile_info.py- Display Hypothesis profile information14_recent_activity.py- Show most recent annotations with contextPhase 3: Documentation
examples/README.md- Overview, setup instructions, fixture explanationexamples/FIXTURES.md- Document fixture annotation IDs and their purposeREADME.mdto reference examplesImplementation Notes
Authentication Pattern
Fixture Discovery
Self-Contained Pattern
Acceptance Criteria