Skip to content

feat: add wattpad provider - #702

Merged
Kikobeats merged 2 commits into
masterfrom
Kikobeats/add-wattpad-provider
Oct 14, 2026
Merged

Kikobeats merged 2 commits into
masterfrom
Kikobeats/add-wattpad-provider

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Wattpad provider

Provider wattpad
Source API wattpad.com/api/v3/users/<username>?fields=avatar
Inputs Username, leading @
Resolution 256×256 (largest real size)
Resolves to no avatar on 400 NotFound, 16 stock useravatar/<hex> images

Live results

Request Preview Avatar URL
/wattpad/Wattpad link
/wattpad/zzqxnope9917 none 404 not found

Obtained by running this branch's provider through the library (require('./src')().wattpad(input)) on 2026-10-14.

Adds a wattpad provider. unavatar.io/wattpad/<username> now returns the user's Wattpad profile picture at the largest size Wattpad serves.

How it works

  • Endpoint: GET https://www.wattpad.com/api/v3/users/<username>?fields=avatar. Public JSON, no auth, no HTML scraping.
  • The API returns a 128px URL like useravatar/Wattpad.128.838617.jpg. The provider rewrites the size segment to 256, the largest size Wattpad renders. Sizes it does not support (300, 400, 512, 1024) return 200 but silently fall back to a 64px image, so 256 is the real ceiling (measured with sips).
  • Missing users get HTTP 400 {"error_code":1014,"error_type":"NotFound"}, which resolves to undefined.
  • Users without a custom avatar get one of 16 stock images, useravatar/<hex digit>.128.jpg, with no per-user id. Those resolve to undefined.
  • A leading @ is stripped, since /users/@Wattpad hits a 400 InvalidEndpoint.

Live evidence

$ curl -s 'https://www.wattpad.com/api/v3/users/Wattpad?fields=avatar'
{"avatar":"https:\/\/img.wattpad.com\/useravatar\/Wattpad.128.838617.jpg"}

$ curl -s 'https://www.wattpad.com/api/v3/users/unavatar-nope-zz9q81?fields=avatar' -w ' HTTP %{http_code}'
{"error_code":1014,"error_type":"NotFound","message":"User not found","fields":["name"]} HTTP 400

$ curl -s 'https://www.wattpad.com/api/v3/users/Rayan1491?fields=avatar'
{"avatar":"https:\/\/img.wattpad.com\/useravatar\/c.128.jpg"}

The provider run with the real got, with each returned URL fetched:

Wattpad              -> https://img.wattpad.com/useravatar/Wattpad.256.838617.jpg 200 image/jpeg 4627B
@WattpadOriginals    -> https://img.wattpad.com/useravatar/WattpadOriginals.256.327027.jpg 200 image/jpeg 4866B
Rayan1491            -> undefined   (stock default avatar)
unavatar-nope-zz9q81 -> undefined   (missing user)

Tests

  • npx ava test/unit/providers/wattpad.js test/unit/providers/index.js test/unit/providers/html-config.js: 101 passed.
  • npx ava (full suite): 549 passed.
  • npx standard on the changed JS files: clean.

The unit tests stub got and assert literal URLs for the API URL, @ stripping, encoding, the size rewrite (including a username that contains digits and dots), stock defaults, missing users, and empty bodies.

Known gap

Some recent accounts have a generated letter tile (for example, a grey square with a "G") stored under a per-user URL such as useravatar/Jihadelamer11.128.972906.jpg. The API exposes no flag for it, and the URL has the same shape as an uploaded photo. These still resolve as avatars.

🤖 Generated with Claude Code


Note

Low Risk
Additive provider with isolated outbound API calls and unit tests; no changes to auth, billing, or existing provider behavior.

Overview
Adds Wattpad as a username provider so unavatar.io/wattpad/<username> can resolve profile pictures.

The new provider calls Wattpad’s public GET /api/v3/users/<username>?fields=avatar endpoint (JSON via got, no HTML scraping). It strips a leading @, URL-encodes the username, upgrades the returned image URL from 128px to 256px, and returns undefined on HTTP errors, missing users, empty avatars, and the 16 shared stock useravatar/<hex> defaults.

wattpad is wired into the provider registry and username tier in src/providers/index.js, documented in README, and covered by unit tests for URL building, size rewriting, stock-avatar filtering, and API success/error paths.

Reviewed by Cursor Bugbot for commit e9df9cf. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8e23b245-16c0-48d4-b33a-e937fdb2eb81
📥 Commits

Reviewing files that changed from the base of the PR and between d8d7b58 and e9df9cf.

📒 Files selected for processing: 4
  • README.md
  • src/providers/index.js
  • src/providers/wattpad.js
  • test/unit/providers/wattpad.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Oct 14, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 38597060574

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.02%) to 97.709%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 36 of 36 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4009
Covered Lines: 3955
Line Coverage: 98.65%
Relevant Branches: 1229
Covered Branches: 1163
Branch Coverage: 94.63%
Branches in Coverage %: Yes
Coverage Strength: 7.01 hits per line

💛 - Coveralls

@Kikobeats
Kikobeats merged commit 54e7d9e into master Oct 14, 2026
3 checks passed
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.

2 participants