AI Chat PDF

AI Chatbot for PDF1

Domain

https://api-chatpdf.dev.apero.vn/

Register device

POST /auth/register-device

Register device for authenticate

Headers

NameValue

Content-Type

application/json

Body

NameTypeDescription

deviceId

string

ID of mobile device

Response

{
    "data": {
        "quota": {
            "filePerDay": 1,
            "questionPerDay": 3
        },
        "userType": "ANONYMOUS",
        "deviceId": "111111111",
        "isSync": false,
        "location": "mobile",
        "email": "",
        "_id": "660e16e7afe07d7c7bc3acc6",
        "createdAt": "2024-04-04T02:56:39.645Z",
        "updatedAt": "2024-04-04T02:56:39.645Z",
        "__v": 0
    },
    "success": true
}

Upload file

POST /upload/register-file

Upload new file want to ask bot by form-data. This api will provide to you sourceId and conversationId <_id> that can use it for later.

Headers

NameValue

Content-Type

application/json

Device-Id

<deviceId>

Body

NameTypeDescription

file

buffer

File upload. Accept PDF only

page

number

Number pages of file. Optional

Response

{
    "data": {
        "conversation": {
            "fileId": "660e1875afe07d7c7bc3accd",
            "deviceId": "66051aa795d1242e7cf304c2",
            "totalMessages": 0,
            "title": "Sample.pdf",
            "sourceId": "src_h1EzrQr5p2ochdf9vb5FI",
            "_id": "660e1875afe07d7c7bc3acd1",
            "createdAt": "2024-04-04T03:03:17.311Z",
            "updatedAt": "2024-04-04T03:03:17.311Z",
            "__v": 0,
            "summary": "",
            "lastMessage": "",
            "fileType": "pdf"
        }
    },
    "success": true
}

Chat

GET /messages/chatting

Chat with bot in file context upload previous. Using Server-Send-Event

Headers

NameValue

Content-Type

application/json

Device-Id

<deviceId>

Query

NameTypeDescription

sourceId

string

Source Id was came from response of api Upload File

message

string

Question of user or bot. In case isReGenerate is true, the message is the re-generate message.

isReGenerate

boolean

Mark the message is generate or not. Default false

Response is SSE

Get conversations

GET /conversations

List all conversations of user

Headers

NameValue

Content-Type

application/json

Device-ID

<deviceId>

Query

NameTypeDescription

page

number

The number page

limit

number

The records per page

Response

{
    "data": {
        "items": [
            {
                "_id": "660e1875afe07d7c7bc3acd1",
                "deviceId": "66051aa795d1242e7cf304c2",
                "totalMessages": 3,
                "title": "Sample.pdf",
                "sourceId": "src_h1EzrQr5p2ochdf9vb5FI",
                "createdAt": "2024-04-04T03:03:17.311Z",
                "updatedAt": "2024-04-04T03:08:49.041Z",
                "fileType": "pdf",
                "fileId": "660e1875afe07d7c7bc3accd",
                "lastMessage": "The content of the file includes detailed information about Pham Nam Trung's work experience, education, certifications, and contact details. It also mentions the projects he has worked on, his objectives, and links to his social media profiles.",
                "summary": ""
            },
            {
                "_id": "66051b2157da8ea33a90a0fe",
                "deviceId": "66051aa795d1242e7cf304c2",
                "totalMessages": 5,
                "title": "Tài liệu không có tiêu đề.pdf",
                "sourceId": "src_0qH13PNPRJcqVOtUXF7cg",
                "createdAt": "2024-03-28T07:24:17.025Z",
                "updatedAt": "2024-04-04T03:12:47.856Z",
                "fileType": "pdf",
                "fileId": "66051b2057da8ea33a90a0fa",
                "lastMessage": "The file mentions Lê Đức Trung as the Trademark Owner and the authorized person for the brand hondaotienich.",
                "summary": ""
            }
        ],
        "totalItems": 2,
        "page": 1,
        "limit": 3,
        "totalPages": 1,
        "paging": false
    },
    "success": true
}

Get contents of conversation

POST /messages/conversation/:conversationId

Get all messages of specific conversation

Headers

NameValue

Content-Type

application/json

DeviceId

<deviceId>

Query

NameTypeDescription

page

number

The number page

limit

number

The records per page

Response

{
    "data": {
        "items": [
            {
                "_id": "660e1aafafe07d7c7bc3ace8",
                "conversationId": "66051b2157da8ea33a90a0fe",
                "message": "The file mentions Lê Đức Trung as the Trademark Owner and the authorized person for the brand hondaotienich.",
                "to": null,
                "author": "bot",
                "createdAt": "2024-04-04T03:12:47.853Z",
                "updatedAt": "2024-04-04T03:12:47.853Z",
                "__v": 0
            },
            {
                "_id": "660e1aadafe07d7c7bc3ace4",
                "conversationId": "66051b2157da8ea33a90a0fe",
                "message": "Who is mentioned in this file?",
                "from": "66051aa795d1242e7cf304c2",
                "to": null,
                "author": "user",
                "createdAt": "2024-04-04T03:12:45.997Z",
                "updatedAt": "2024-04-04T03:12:45.997Z",
                "__v": 0
            },
            {
                "_id": "66051b4157da8ea33a90a10a",
                "conversationId": "66051b2157da8ea33a90a0fe",
                "message": "This PDF file authorizes Đồ da dụng Trung Thành to sell and distribute hondaotienich branded products until February 10, 2028. The authorization can be revoked with a 30-day notice.\n\nThree relevant questions from this file could be:\n1. Who is authorized to sell and distribute hondaotienich branded products?\n2. What is the valid period of the authorization granted in this document?\n3. How much notice is required for revoking the authorization mentioned in this file?",
                "to": null,
                "author": "bot",
                "createdAt": "2024-03-28T07:24:49.262Z",
                "updatedAt": "2024-03-28T07:24:49.262Z",
                "__v": 0
            },
            {
                "_id": "66051b3d57da8ea33a90a106",
                "conversationId": "66051b2157da8ea33a90a0fe",
                "message": "Please summarize this file and Provide me with the 3 most relevant questions of this file",
                "from": "66051aa795d1242e7cf304c2",
                "to": null,
                "author": "user",
                "createdAt": "2024-03-28T07:24:45.995Z",
                "updatedAt": "2024-03-28T07:24:45.995Z",
                "__v": 0
            },
            {
                "_id": "66051b2457da8ea33a90a100",
                "conversationId": "66051b2157da8ea33a90a0fe",
                "message": "This PDF file is an authorization document granting Đồ da dụng Trung Thành the right to sell and distribute hondaotienich branded products until February 10, 2028, with the ability to revoke the authorization with a 30-day notice.\n\nThree relevant questions from this file could be:\n1. Who is the registrant of the hondaotienich trademark?\n2. What company is authorized to sell and distribute hondaotienich branded products?\n3. What is the valid period of the authorization granted in this document?",
                "to": null,
                "author": "bot",
                "createdAt": "2024-03-28T07:24:20.243Z",
                "updatedAt": "2024-03-28T07:24:20.243Z",
                "__v": 0
            }
        ],
        "totalItems": 5,
        "page": 1,
        "limit": 5,
        "totalPages": 1,
        "paging": false
    },
    "success": true
}

Summarize file

GET /conversations/summarize

Get summarize of file upload

Headers

NameValue

Content-Type

application/json

Device-ID

<deviceId>

Query string

NameTypeDescription

sourceId

string

ID of mobile device

Response is SSE

Update conversation

PUT /conversations/:conversationId

Update content of specific conversation

Headers

NameValue

Content-Type

application/json

Device-ID

<deviceId>

Params

NameTypeDescription

conversationId

string

Id of conversation

Body

NameTypeDescription

title

string

Title of conversation

Response

{
    "data": {
        "_id": "660e1875afe07d7c7bc3acd1",
        "fileId": {
            "_id": "660e1875afe07d7c7bc3accd",
            "metadata": {
                "fileType": "pdf",
                "fileName": "Pham_Nam_Trung_Junior_Python.pdf",
                "fileSize": 219836,
                "sourceId": "src_h1EzrQr5p2ochdf9vb5FI"
            }
        },
        "deviceId": "66051aa795d1242e7cf304c2",
        "totalMessages": 3,
        "title": "This is new title",
        "sourceId": "src_h1EzrQr5p2ochdf9vb5FI",
        "createdAt": "2024-04-04T03:03:17.311Z",
        "updatedAt": "2024-04-05T03:12:51.693Z",
        "__v": 0
    },
    "success": true
}

Delete conversation

DELETE /conversations/:conversationId

Delete conversation already exists and belongs to user

Headers

NameValue

Content-Type

application/json

Device-Id

<deviceId>

Params

NameTypeDescription

conversationId

string

Id of conversation

Response

{
    "data": true,
    "success": true
}

Upgrade Plan

PUT /user/upgrade-plan

Upgrade new plan of user

Headers

NameValue

Content-Type

application/json

Device-Id

<deviceId>

Body

NameTypeDescription

packageType

string

Accept 3 values: base, plus, ultimate

Response

{
    "data": {
        "quota": {
            "fileSize": 33554432,
            "filePerMonth": 300,
            "questionPerMonth": 30,
            "fileCappacity": 120,
            "fileTypes": [
                "pdf"
            ]
        },
        "_id": "66051aa795d1242e7cf304c2",
        "userType": "ANONYMOUS",
        "deviceId": "5555",
        "isSync": false,
        "location": "mobile",
        "email": "",
        "createdAt": "2024-03-28T07:22:15.861Z",
        "updatedAt": "2024-04-09T07:56:55.503Z",
        "__v": 2
    },
    "success": true
}

Get user quota

GET /user/quota

Get quota of user

Headers

NameValue

Content-Type

application/json

Device-Id

<deviceId>

NameTypeDescription

name

string

Name of the user

age

number

Age of the user

Response

{
    "data": {
        "quota": {
            "fileSize": 33554432,
            "fileTypes": [
                "pdf"
            ],
            "fileCappacity": 120,
            "filePerMonth": 2999,
            "pagePerMonth": 1000,
            "questionPerMonth": 96,
            "questionPerDay": 0,
            "remainingPages": 997,
            "remainingQuestions": 93
        },
        "_id": "661756de0e9bea7aba4eed29",
        "userType": "ANONYMOUS",
        "deviceId": "quota_pro",
        "isSync": false,
        "location": "mobile",
        "email": "",
        "createdAt": "2024-04-11T03:19:58.840Z",
        "updatedAt": "2024-04-11T03:51:11.742Z",
        "__v": 0
    },
    "success": true
}

Last updated