Skip to main content

Parse, classify, and normalize Pinterest URLs without network requests

Project description

pinterest-url-normalizer

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

SavePinner · 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 is maintained by the team behind SavePinner, a browser tool for inspecting media exposed by public Pinterest Pin URLs. The package 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

Project details


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.0.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.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pinterest_url_normalizer-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 876fcf98040a94932f85de1134bf0cafe03d55deebe6df9881b336c90a7814b8
MD5 ae5f1870f43319d8c1d44a894974c4b8
BLAKE2b-256 8fe2354069a55b034760ab74de2104e2fece1421e98c009d64eb4ec3e2bdc4fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinterest_url_normalizer-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pinterest_url_normalizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b72eccf55f0664d192c71ce3e3a035fa82ceb856719303b83e15bb5b1179318
MD5 bd2f7b73e55d7bc4dad21fc0502f3605
BLAKE2b-256 a7b9e13a19182eec312e2a9dda35a0a6f23131cad5ce5a8b9b573dbebebb11f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinterest_url_normalizer-0.1.0-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page