Skip to main content

An unofficial Python client library for interacting with Perplexity AI through its web interface.

Project description

Perplexity WebUI Scraper

Unofficial Python client for Perplexity AI.

PyPI Python License


Installation

uv pip install perplexity-webui-scraper

Requirements

  • Perplexity Pro subscription
  • Session token (__Secure-next-auth.session-token cookie from browser)

Getting Your Session Token

  1. Log in at perplexity.ai
  2. Open DevTools (F12) → Application → Cookies
  3. Copy __Secure-next-auth.session-token value
  4. Store in .env: PERPLEXITY_SESSION_TOKEN=your_token

Quick Start

from perplexity_webui_scraper import Perplexity

client = Perplexity(session_token="YOUR_TOKEN")
conversation = client.create_conversation()

conversation.ask("What is quantum computing?")
print(conversation.answer)

# Follow-up
conversation.ask("Explain it simpler")
print(conversation.answer)

Streaming

for chunk in conversation.ask("Explain AI", stream=True):
    print(chunk.answer)

With Options

from perplexity_webui_scraper import (
    ConversationConfig,
    Coordinates,
    Models,
    SourceFocus,
)

config = ConversationConfig(
    model=Models.RESEARCH,
    source_focus=[SourceFocus.WEB, SourceFocus.ACADEMIC],
    language="en-US",
    coordinates=Coordinates(latitude=40.7128, longitude=-74.0060),
)

conversation = client.create_conversation(config)
conversation.ask("Latest AI research", files=["paper.pdf"])

API

Perplexity(session_token, config?)

Parameter Type Description
session_token str Browser cookie
config ClientConfig Timeout, TLS, etc.

Conversation.ask(query, model?, files?, citation_mode?, stream?)

Parameter Type Default Description
query str Question (required)
model Model Models.BEST AI model
files list[str] None File paths
citation_mode CitationMode CLEAN Citation format
stream bool False Enable streaming

Models

Model Description
Models.BEST Auto-select best
Models.RESEARCH Deep research
Models.SONAR Fast queries
Models.GPT_51 OpenAI GPT-5.1
Models.CLAUDE_45_SONNET Claude 4.5 Sonnet
Models.GEMINI_3_PRO_THINKING Gemini 3.0 Pro
Models.GROK_41 xAI Grok 4.1

CitationMode

Mode Output
DEFAULT text[1]
MARKDOWN text[1](url)
CLEAN text (no citations)

ConversationConfig

Parameter Default Description
model Models.BEST Default model
citation_mode CLEAN Citation format
save_to_library False Save to library
search_focus WEB Search type
source_focus WEB Source types
time_range ALL Time filter
language "en-US" Response language
timezone None Timezone
coordinates None Location (lat/lng)

Disclaimer

This is an unofficial library. It uses internal APIs that may change without notice. Use at your own risk. Not for production use.

By using this library, you agree to Perplexity AI's Terms of Service.

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

perplexity_webui_scraper-0.3.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

perplexity_webui_scraper-0.3.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file perplexity_webui_scraper-0.3.2.tar.gz.

File metadata

  • Download URL: perplexity_webui_scraper-0.3.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for perplexity_webui_scraper-0.3.2.tar.gz
Algorithm Hash digest
SHA256 51d284366471a5e2a2f4708110ce40c3b6b05a66fd6f0b57643d194665f2d46d
MD5 fb0c5d7b24faebabbd2d1c1e0d58ec88
BLAKE2b-256 81d67d3d4a238de7bacb4ef5816770392142122f45b098db307d134a5d738126

See more details on using hashes here.

File details

Details for the file perplexity_webui_scraper-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: perplexity_webui_scraper-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for perplexity_webui_scraper-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 894363c04492f986aae4125384b216bec8840cdd5d2edc891fab2ea165265bde
MD5 05bee0beca34a72345764de0ebe108c6
BLAKE2b-256 1058a3684971958806dbb3836ca6d2397a934d70d9c7a7c626146b0eece51234

See more details on using hashes here.

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