Skip to main content
POST
/
source
/
ingestSource
Ingest Source
curl --request POST \
  --url https://api.example.com/source/ingestSource \
  --header 'api-key: <api-key>'

Description

This endpoint allows you to ingest a new learning source into the system. Supported source types include YouTube videos, web pages, lecture audio/video, and PDF files. Depending on the source type, you can either provide a URL (for online sources) or upload a file (for PDFs). The ingested source will be processed and made available for generating educational content such as quizzes, flashcards, and mind maps.

Example Request (YouTube)

curl -X POST \
  'https://b2b-api-backend-95487.ondigitalocean.app/source/ingestSource' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'api-key: <your-api-key>' \
  -d '{
    "source": {
      "sourceType": "youtube",
      "userId": "user-123",
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      "metadata": { "topic": "Algebra" }
    }
  }'

Example Request (File)

curl -X POST \
  'https://b2b-api-backend-95487.ondigitalocean.app/source/ingestSource' \
  -H 'accept: application/json' \
  -H 'api-key: <your-api-key>' \
  -F 'file=@/path/to/your/file.pdf' \
  -F 'source={"sourceType":"file","userId":"user-123","metadata":{"topic":"Calculus"}}'

Example Value (Response)

{
  "_id": "65f2...",
  "orgId": "65f1c0f5a2b3c4d5e6f7a8b9",
  "userId": "user-123",
  "sourceType": "youtube",
  "content": "Transcribed content...",
  "metadata": { "topic": "Algebra" },
  "createdAt": "2024-03-12T10:00:00.000Z",
  "updatedAt": "2024-03-12T10:00:00.000Z"
}

Response Fields

  • _id: MongoDB ObjectId of the created source
  • orgId: Organisation ID
  • userId: User identifier
  • sourceType: Type of the source
  • content: Processed content from the source
  • metadata: Additional metadata
  • createdAt: Timestamp of creation
  • updatedAt: Timestamp of last update

Authentication

api-key
string
required
Your organisation’s API key

Endpoint Details

  • Method: POST
  • Path: /source/ingestSource
  • Authentication: Required
  • Response Status: 201 Created

Request Parameters

  • Headers:
    • api-key: <your-api-key>
  • Body (YouTube, Webpage, Lecture):
    {
      "source": {
        "sourceType": "youtube",
        "userId": "user-123",
        "url": "https://www.youtube.com/watch?v=...",
        "metadata": { "topic": "Algebra" }
      }
    }
    
  • Body (File):
    • multipart/form-data with fields:
      • file: PDF file
      • source: JSON string, e.g. { "sourceType": "file", "userId": "user-123", "metadata": { "topic": "Calculus" } }

Further Explanation

  • For YouTube, Webpage, and Lecture sources, send the request as application/json.
  • For PDF files, use multipart/form-data.
  • The response contains the processed content and metadata for the ingested source.