8000 GitHub - Arbaaz-Mahmood/Perplexity-API: Unofficial Selenium Based API for Perplexity. Bonus: A typescript implementation of the API via puppeteer · GitHub
[go: up one dir, main page]

Skip to content

About

Unofficial Selenium Based API for Perplexity. Bonus: A typescript implementation of the API via puppeteer

Resources

Stars

11 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Perplexity Query API

This project offers both a TypeScript server (Node.js and Express) and a Python script to query the perplexity.ai website and fetch answers to user's questions. Both implementations use browser automation: the TypeScript server uses Puppeteer, while the Python script uses Selenium.

Prerequisites

  • Node.js (v14.0.0 or higher) and npm (v6.14.0 or higher) for TypeScript server
  • Python (3.6 or higher) for Python script

TypeScript Server Installation and Usage

  1. Clone the repository or download the source code.
git clone https://github.com/Arbaaz-Mahmood/Perplexity-API.git
  1. Navigate to the project directory.
cd perplexity-query-api
  1. Install the required dependencies.
npm install
  1. Run the server using ts-node:
npx ts-node app.ts

The server will start at http://localhost:3000 by default. Users can send a POST request to the /query endpoint with a JSON payload that includes a prompt field.

Python Script Installation and Usage

  1. Install the required Python packages:
pip install selenium beautifulsoup4 webdriver-manager
  1. Install ChromeDriver:
  • macOS:
    • You can use Homebrew to install ChromeDriver: brew install chromedriver
    • Make sure the installed ChromeDriver is in your PATH environment variable.
  • Windows:
    • Download ChromeDriver from the official site.
    • Extract the executable and add the folder containing the executable to your PATH environment variable.
  • Linux:
    • Use the package manager for your distribution to install ChromeDriver.
    • For example, on Ubuntu-based systems: sudo apt-get install chromium-chromedriver
    • Make sure the installed ChromeDriver is in your PATH environment variable.
  1. Run the perplexity_query.py script:
python perplexity_query.py

The Python script will prompt for a question, interact with the perplexity.ai website, and print the response to the console.

License

This project is licensed under the MIT License. See the LICENSE file for the full license text.

About

Unofficial Selenium Based API for Perplexity. Bonus: A typescript implementation of the API via puppeteer

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0