Skip to main content

pinterest-url-normalizer

Parse, classify, and normalize Pinterest URLs without making network requests.

TypeScript package on JSR · Source code

The package recognizes Pin, pin.it, profile, board, and Ideas URLs across Pinterest country domains. It uses an exact host allow list, rejects HTTP URLs and lookalike domains, and removes tracking parameters from normalized output.

Install

python -m pip install pinterest-url-normalizer

Python API

from pinterest_url_normalizer import (
    is_pinterest_url,
    normalize_pinterest_url,
    parse_pinterest_url,
)

parsed = parse_pinterest_url("https://de.pinterest.com/pin/987654321/?utm_source=share")

print(parsed.kind)  # pin
print(parsed.pin_id)  # 987654321
print(parsed.normalized_url)  # https://www.pinterest.com/pin/987654321/

is_pinterest_url("https://pin.it/AbC123")
normalize_pinterest_url("https://pinterest.co.uk/savepinner/media-tools/")

Command line

Normalize URL arguments:

pinterest-url-normalizer \
  "https://pinterest.co.uk/pin/123/?utm_source=share" \
  "https://pin.it/AbC123"

Or pipe one URL per line and emit JSON Lines:

printf '%s\n' 'https://www.pinterest.com/pin/123/' | \
  pinterest-url-normalizer --json

The command exits with status 1 when any input is invalid and 2 when no input is provided.

Supported URL kinds

Kind Example
pin https://www.pinterest.com/pin/123456789/
short https://pin.it/AbC123
profile https://www.pinterest.com/savepinner/
board https://www.pinterest.com/savepinner/media-tools/
ideas https://www.pinterest.com/ideas/space-wallpaper/926295399832/

pin.it links are classified and normalized but are not followed. Resolving them requires a network request and belongs in the consuming application.

API

  • parse_pinterest_url(value) returns an immutable ParsedPinterestUrl. It raises PinterestUrlError with code INVALID_URL or UNSUPPORTED_URL on failure.
  • normalize_pinterest_url(value) returns the canonical URL.
  • is_pinterest_url(value) validates a supported URL form.
  • is_pinterest_host(host) checks a hostname against the exact country-domain allow list.

Why this package exists

This parser only prepares canonical links; it never fetches media. When a public Pin contains a still image, continue in the SavePinner image downloader to compare the image and thumbnail variants exposed for that Pin. The package itself contains no downloader, tracking, browser automation, or remote code.

Pinterest is a trademark of Pinterest, Inc. This project is independent and is not affiliated with or endorsed by Pinterest.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinterest_url_normalizer-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pinterest_url_normalizer-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pinterest_url_normalizer-0.1.1.tar.gz.

File metadata

  • Download URL: pinterest_url_normalizer-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pinterest_url_normalizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ad8f21a7df386be51ee592828b6d06c35fafd1a107fa2eb3bbd8d531af802ad0
MD5 ded1623bc021a2e71f93b3d5d089f683
BLAKE2b-256 0f7bd3f7f2c068b46b5a5b115e66184ee213899cbdd6efcc9485c98d9767c4b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinterest_url_normalizer-0.1.1.tar.gz:

Publisher: publish-pypi.yml on jiankn/pinterest-url-normalizer-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pinterest_url_normalizer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pinterest_url_normalizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5eb78b64043c0b7e46332d2059cf036c67f1de804f1c65ffe8d97ba0a0f5546b
MD5 e11bd16d0e6b221d7f74f5d94b03447d
BLAKE2b-256 8df0a66c55f20f9840fb368c0e51f94d1d5a0a8ab44dc85b2b1e7bba5a8f39a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinterest_url_normalizer-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on jiankn/pinterest-url-normalizer-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page