Skip to content

feat: client.colorways.get_photo() for crowd-sourced colorway photos (issue #8)#9

Merged
gx1400 merged 1 commit into
mainfrom
issue-8-colorway-photo
May 23, 2026
Merged

feat: client.colorways.get_photo() for crowd-sourced colorway photos (issue #8)#9
gx1400 merged 1 commit into
mainfrom
issue-8-colorway-photo

Conversation

@gx1400
Copy link
Copy Markdown
Contributor

@gx1400 gx1400 commented May 23, 2026

Summary

  • New client.colorways.get_photo(yarn_id, colorway_id) returns Optional[ColorwayPhoto] by querying GET /projects/search.json?yarn_id=X&colorway_id=Y&page_size=1 and extracting first_photo — the same image Ravelry shows on colorway grid tiles
  • AsyncColorways.get_photo() is the async counterpart
  • ColorwayPhoto gains small_url (third size variant from the API)
  • ProjectsResponse gains first_photo: Optional[ColorwayPhoto] = None
  • Colorway docstring updated to clarify photos is never populated by the yarn embed and to direct callers to get_photo()
  • client.colorways wired onto both RavelryClient and AsyncRavelryClient
  • resources.md and quickstart.md updated with get_photo() usage
  • 10 new tests; full suite 210 passed
  • Version 0.2.2

Why not GET /colorways/{id}.json?

That endpoint redirects to the Ravelry login page for all developer credential types. The projects/search.json path with yarn_id + colorway_id is the documented approach Ravelry itself uses.

Test plan

  • get_photo returns ColorwayPhoto when first_photo present in response
  • Returns None when first_photo is null or absent
  • Sends correct yarn_id, colorway_id, page_size=1 query params
  • Raises RavelryAPIError on 401 and 404
  • Colorway.photos is empty list from yarn embed (regression)
  • 210 tests pass

Closes #8

Generated with Claude Code

- Add Colorways resource sub-client with get_photo(yarn_id, colorway_id)
  returning Optional[ColorwayPhoto] via GET /projects/search.json?first_photo
- Add AsyncColorways with async get_photo() counterpart
- Wire client.colorways onto RavelryClient and AsyncRavelryClient
- Add small_url field to ColorwayPhoto
- Add first_photo: Optional[ColorwayPhoto] to ProjectsResponse
- Document that Colorway.photos is never populated by the yarn embed
- Add ColorwayPhoto to responses.py imports
- Add 10 tests (get_photo present/null/absent, URL params, errors, regression)
- Update resources.md with colorway photo section and client.colorways table row
- Update quickstart.md with get_photo usage example
- Bump version to 0.2.2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gx1400 gx1400 merged commit 35d9f69 into main May 23, 2026
3 checks passed
@gx1400 gx1400 deleted the issue-8-colorway-photo branch May 23, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add colorway photo lookup via projects/search endpoint

1 participant