Skip to content

Web app and API ​

Markdrop Web is a converter you host yourself. It has a web page for converting files, web pages and YouTube links, and a REST API that scripts, the browser extension and the Telegram bot can call. New to APIs? Read What is an API? first.

Run it ​

Markdrop Web runs from the source code. Get it first:

bash
git clone https://github.com/Dhiva-Labs/markdrop.git
cd markdrop/04-web-app

With Python ​

The project's own instructions use uv to create the Python environment:

bash
cd backend
uv venv .venv && uv pip install -p .venv/bin/python -r requirements.txt
.venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8460 --reload

Open http://127.0.0.1:8460.

With Docker ​

bash
docker build -t md-converter .
docker run -p 8000:8000 -e MD_API_KEY=changeme md-converter

Open http://localhost:8000. Replace changeme with a key of your own; see Security.

Use the web page ​

The page has three tabs:

TabWhat to do
Upload fileDrop a file on the box, or click to choose one.
Web page / file URLPaste the address of a page, or a direct link to a .pdf, .docx or other file, and select Convert. Wikipedia pages and RSS feeds get special handling.
YouTubePaste a video link and select Get transcript. You get the title, channel, description and full transcript.

The result appears below, with Copy and Download .md buttons. The supported formats link at the bottom lists what the server can convert.

API endpoints ​

MethodPathBody
POST/api/convert/fileMultipart form with a file field. Optional extension, mimetype and charset fields help with unusual files.
POST/api/convert/urlJSON {"url": "..."}
POST/api/convert/youtubeJSON {"url": "..."}
GET/api/formatsNone. Lists the formats the server supports.
GET/api/healthNone.

Convert a file ​

bash
curl -F "file=@report.docx" http://127.0.0.1:8460/api/convert/file

Convert a web page ​

bash
curl -X POST http://127.0.0.1:8460/api/convert/url \
  -H "Content-Type: application/json" \
  -d '{"url": "https://en.wikipedia.org/wiki/Markdown"}'

Get a YouTube transcript ​

bash
curl -X POST http://127.0.0.1:8460/api/convert/youtube \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.youtube.com/watch?v=VIDEO_ID"}'

The response ​

A successful conversion returns:

json
{
  "ok": true,
  "title": "Markdown - Wikipedia",
  "markdown": "---\ntitle: Markdown - Wikipedia\nsource: https://en.wikipedia.org/wiki/Markdown\n...",
  "source": "https://en.wikipedia.org/wiki/Markdown",
  "warnings": []
}

The markdown field starts with the usual front-matter. See JSON basics if this format is new to you.

Errors ​

StatusMeaning
400Bad input: an empty upload, a link that is not allowed, or a link that is not a YouTube watch or Shorts address.
401The server requires an API key and the X-API-Key header is missing or wrong.
413The file or download is larger than the limit, 50 MB by default.
415No converter can handle this type of input.
422The conversion failed. The error field says why.
429Too many requests from your address. Wait and try again.
502The server could not fetch the URL.
504The conversion took longer than the time limit.

Configuration ​

Set these environment variables before starting the server.

VariableDefaultWhat it does
MD_API_KEYEmpty (no key needed)When set, every request must send this value in the X-API-Key header.
MD_MAX_UPLOAD_BYTES50 MBThe largest file you can upload.
MD_MAX_DOWNLOAD_BYTES50 MBThe largest file the server downloads from a URL.
MD_CONVERT_TIMEOUT60 secondsThe time limit for one conversion.
MD_WORKERS2How many conversions can run at the same time.
MD_RATE_PER_MINUTE30Requests allowed per minute from one address.
MD_RATE_BURST10Requests allowed in a quick burst from one address.
MD_CORS_ORIGINS*Which websites may call the API from a browser, comma-separated.
MD_FETCH_TIMEOUT30 secondsThe time limit for downloading a URL.
MD_ALLOW_PRIVATE_URLSOffAllows URLs on private networks. For development only.

With an API key set, send it like this:

bash
curl -H "X-API-Key: your-key" -F "file=@report.docx" http://127.0.0.1:8460/api/convert/file

Security ​

  • Set MD_API_KEY whenever the server can be reached by other people. Without it, anyone who can reach the server can use it.
  • Private addresses are blocked. The URL endpoint refuses links to private and local network addresses, and checks every redirect, so the server cannot be used to reach machines on your internal network. Leave MD_ALLOW_PRIVATE_URLS off outside development.
  • Limit browser access. Set MD_CORS_ORIGINS to the websites that should call the API, instead of *.

Next steps ​