└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Phind API Reference 2 | 3 | ## Overview 4 | 5 | Phind is an AI answer engine that provides users with the ability to interact with an AI model to get answers, assistance with queries, and engage in chat conversations. This API reference details the endpoints available for interacting with Phind's services. 6 | 7 | ### This is not finished and subject to change 8 | 9 | You might notice that this doc looks a little barebones - I'm working on properly reverse enginering their backend. For now, this is what you get (the old docs were out of date and a lot had changed!). 10 | 11 | 12 | ## Authentication 13 | 14 | ### Get Session 15 | 16 | - **Endpoint:** `GET /api/auth/session` 17 | - **Description:** Retrieves the current session information for the user. 18 | - **Headers:** 19 | - `Accept`: `*/*` 20 | - `Accept-Encoding`: `gzip, deflate, br` 21 | - `Accept-Language`: Language preferences (e.g., `en-GB,en;q=0.9,en-US;q=0.8`) 22 | - **Query Parameters:** 23 | - None. 24 | - **Response:** 25 | - **Status Code:** `304 Not Modified` (if session is unchanged) or `200 OK` (if a new session is created). 26 | - **Content-Type:** `application/json` 27 | - **Body:** An empty JSON object `{}` or session details. 28 | 29 | ## Querying 30 | 31 | ### Make a Query 32 | 33 | - **Endpoint:** `POST https://https.api.phind.com/infer/` 34 | - **Description:** Submits a user's question to the AI model and receives an answer. 35 | - **Headers:** 36 | - `Content-Type`: `application/json;charset=UTF-8` 37 | - `Origin`: `https://www.phind.com` 38 | - **Payload:** 39 | - `question`: The user's query. 40 | - `options`: Various options for customizing the query (e.g., `date`, `language`, `detailed`, etc.). 41 | - `context`: Optional context for the question. 42 | - `challenge`: A numeric value included for anti-fraud or verification purposes. 43 | - **Response:** 44 | - **Status Code:** `200 OK` 45 | - **Content-Type:** `text/event-stream; charset=utf-8` 46 | - **Body:** A stream of events containing the AI's responses and follow-up prompts. 47 | 48 | ### Cache Query Result 49 | 50 | - **Endpoint:** `POST /api/db/cache` 51 | - **Description:** Stores the results of a query in cache. 52 | - **Headers:** 53 | - `Content-Type`: `application/json;charset=UTF-8` 54 | - `Origin`: `https://www.phind.com` 55 | - **Payload:** 56 | - `title`: The title of the query. 57 | - `value`: An array containing the query and its result. 58 | - `challenge`: A numeric value for verification. 59 | - **Response:** 60 | - **Status Code:** `200 OK` 61 | - **Content-Type:** `application/json; charset=utf-8` 62 | - **Body:** A JSON object containing a `request_id`. 63 | 64 | ## Chat 65 | 66 | ### Preflight Request 67 | 68 | - **Endpoint:** `OPTIONS https://https.api.phind.com/agent/` 69 | - **Description:** A preflight request for CORS that precedes the actual request to the chat endpoint. 70 | - **Headers:** 71 | - `Access-Control-Request-Headers`: `content-type` 72 | - `Access-Control-Request-Method`: `POST` 73 | - `Origin`: `https://www.phind.com` 74 | - **Response:** 75 | - **Status Code:** `200 OK` 76 | - **Content-Type:** `text/plain; charset=utf-8` 77 | - **Headers:** Appropriate CORS headers. 78 | 79 | ### Send Chat Message 80 | 81 | - **Endpoint:** `POST https://https.api.phind.com/agent/` 82 | - **Description:** Sends a message to the AI chat agent and receives a response. 83 | - **Headers:** 84 | - `Content-Type`: `application/json;charset=UTF-8` 85 | - `Origin`: `https://www.phind.com` 86 | - **Payload:** 87 | - `user_input`: The user's chat message. 88 | - `message_history`: An array of previous messages in the conversation. 89 | - `requested_model`: The AI model being used for the chat. 90 | - `anon_user_id`: An anonymous identifier for the user. 91 | - `challenge`: A numeric value for verification. 92 | - **Response:** 93 | - **Status Code:** `200 OK` 94 | - **Content-Type:** `text/event-stream; charset=utf-8` 95 | - **Body:** A stream of events containing the chat agent's responses. 96 | 97 | ### Store Chat Message 98 | 99 | - **Endpoint:** `POST /api/db/chat` 100 | - **Description:** Stores a chat message in the database. 101 | - **Headers:** 102 | - `Content-Type`: `application/json;charset=UTF-8` 103 | - `Origin`: `https://www.phind.com` 104 | - **Payload:** 105 | - `title`: The title or subject of the chat. 106 | - `messages`: An array of message objects with `role`, `content`, and `metadata`. 107 | - `challenge`: A numeric value for verification. 108 | - **Response:** 109 | - **Status Code:** `200 OK` 110 | - **Content-Type:** `application/json; charset=utf-8` 111 | - **Body:** A JSON object with details about the stored chat, including an `id`. 112 | 113 | ## Notes 114 | 115 | - All endpoints are served over HTTPS and require proper headers to be set for CORS and content type. 116 | - The `challenge` field in requests is used for security purposes and may be part of anti-fraud measures. 117 | - Responses, especially those involving AI interactions, are returned as streams of events and may require special handling to process. 118 | - The exact request content and responses will differ per user and context. 119 | - This API Reference is based on observed requests and responses and is unofficial. 120 | --------------------------------------------------------------------------------