ravelpy
Python client for the Ravelry REST API, supporting read-only Basic Auth (public catalog data), personal account keys (full authenticated access), and OAuth 2.0 (scoped delegated access).
Built with Claude AI
The requirements, architecture, and implementation of ravelpy were developed collaboratively with Claude by Anthropic. Claude wrote the majority of the code in this repository through an iterative conversation-driven process. This is disclosed prominently because we believe AI development transparency matters.
Install
pip install ravelpy
To also run the optional Swagger UI server:
pip install "ravelpy[server]"
Auth
Ravelry supports three credential tiers:
| Tier | Credential | Access |
|---|---|---|
| Read-only | Basic Auth with read- prefix username |
Public catalog data only |
| Personal key | Basic Auth with your developer credentials | Full authenticated access; all OAuth scopes granted automatically |
| OAuth 2.0 | Bearer token | Scoped delegated access; requires explicit scope grants |
Get your developer credentials from ravelry.com/pro/developer.
Basic Auth (read-only or personal key)
Set credentials as environment variables (or in a .env file):
RAVELRY_USERNAME=read-xxxxxxxxxxxx # or your personal username
RAVELRY_API_KEY=your_api_key
from ravelpy import RavelryClient
# Read-only key — public catalog data only
client = RavelryClient(username="read-xxxxxxxxxxxx", api_key="your_api_key")
# Personal key — full authenticated access, all scopes auto-granted
client = RavelryClient(username="your_username", api_key="your_personal_key")
OAuth 2.0
from ravelpy import RavelryClient
from ravelpy.oauth import OAuthClient, OAuthScope
oauth = OAuthClient(
client_id="your_client_id",
client_secret="your_client_secret",
)
# Build an auth URL and redirect the user there
url, state = oauth.auth_url(scopes=[OAuthScope.OFFLINE])
# After the user grants access, exchange the code for a token
token = oauth.exchange_code(code="the_code_from_callback")
# Build a RavelryClient from the access token
client = RavelryClient.from_oauth_token(token.access_token)
See docs/authentication.md for the full OAuth scope list, a tested scope matrix, and notes on which endpoints require specific scopes.
Quickstart
RavelryClient is async-only. Use it as an async context manager:
import asyncio
from ravelpy import RavelryClient
async def main():
async with RavelryClient(username="read-xxxxxxxxxxxx", api_key="your_api_key") as client:
# Search for free sock patterns
data, etag, raw = await client.patterns.search(
query="socks", weight="fingering", availability="free"
)
for p in raw["patterns"]:
print(p["name"])
# Get a specific yarn
data, etag, raw = await client.yarns.show(yarn_id=90897)
print(raw["yarn"]["name"])
asyncio.run(main())
For a personal key or OAuth token (required for write endpoints and user data):
async with RavelryClient(username="your_username", api_key="your_personal_key") as client:
data, etag, raw = await client.people.me()
print(raw["user"]["username"])
# Add a yarn to your stash
_, _, raw = await client.stash.create("your_username", {
"yarn_id": 95245,
"colorway_name": "Natural",
"skeins": 3,
})
print("New stash ID:", raw["stash"]["id"])
ETag caching
Every method returns (model, etag, raw_dict). Pass the etag back on subsequent calls — the server returns 304 Not Modified and both model and raw_dict will be None.
data, etag, raw = client.patterns.search(query="socks")
# later...
data, etag, raw = client.patterns.search(query="socks", etag=etag)
if data is None:
print("not modified — use cached data")
API coverage
| Sub-client | Methods |
|---|---|
client.patterns |
search, show, list (multi-get), comments, highlights, projects |
client.pattern_sources |
show, search, patterns |
client.yarns |
show, list (multi-get), search, comments |
client.yarn_companies |
search |
client.reference |
color families, fiber attributes/categories, yarn weights/attributes, pattern attributes/categories, pattern source types, languages, photo sizes |
client.people |
me, show, comments |
client.projects |
search, list, show, comments, crafts, statuses |
client.stash |
list, search, unified_list, show, comments, create |
client.queue |
list, show |
client.favorites |
list, show |
client.fiber |
show, comments |
client.bundles |
list, show, bundled_items, packs |
client.shops |
search, show |
client.groups |
search |
client.stores |
list, products, purchases |
client.forums |
sets, topics, filtered_topics, post, unread_posts |
client.topics |
show, posts |
client.messages |
list, show |
client.needles |
list, sizes, types |
client.designers |
show |
client.products |
show, attachments |
client.deliveries |
list |
client.drafts |
list, show |
client.volumes |
show |
client.pages |
show |
client.packs |
show |
client.friends |
list, activity |
client.library |
search |
client.saved_searches |
list |
client.app |
config, data |
client.extras |
color_families, search |
client.photos |
dimensions, sizes, status |
Swagger UI server
The examples/server.py FastAPI proxy exposes all endpoints with interactive docs:
uvicorn examples.server:app --reload
Open http://localhost:8000/docs.
Links
License
MIT — see LICENSE.
Release files for ravelpy 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ravelpy-0.3.1.tar.gz | 738.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ravelpy-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 793.4 kB
Release files / ravelpy-0.3.1.tar.gz
| Download URL | ravelpy-0.3.1.tar.gz |
|---|---|
| Size | 738.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c900abcd861191f9700452f3a3cbcae85f37339703f2fa3f8783d3f7a0814ec1
|
|
BLAKE2b-256 checksum How to use checksums |
c98933391c98b5a4002f4e3527db06217cff16b8c5c2bc0f0bfa1f918ea9773a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / ravelpy-0.3.1-py3-none-any.whl
| Download URL | ravelpy-0.3.1-py3-none-any.whl |
|---|---|
| Size | 54.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
044e4c9a145b8daaeda0724cdb77cff5355e1c9d058eb7b669fc76d388641bfd
|
|
BLAKE2b-256 checksum How to use checksums |
bd448b3d140e97ba9a3c80637a9dd884101171840e5c25a842fc5ad8c9a6c0a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency log