Skip to Content

Download File

Download the content of a Markdown or MDX file from a project. Returns the raw file content.

Endpoint

GET /api/projects/{project_id}/files/{filename}

Authentication

Required: API key in Authorization header

Authorization: Bearer YOUR_API_KEY

Request

Path Parameters

ParameterTypeRequiredDescription
project_idUUIDYesThe project ID
filenamestringYesThe exact filename (case-sensitive)

Response

Success Response (200 OK)

Headers:

Content-Type: text/markdown; charset=utf-8 Content-Length: 4096 Content-Disposition: attachment; filename="article.mdx" X-File-Size: 4096 X-Created-Date: 2025-01-09T10:00:00Z X-Updated-Date: 2025-01-09T10:00:00Z

Body: Raw file content

Error Responses

StatusErrorDescriptionSolution
401UnauthorizedMissing or invalid authenticationVerify credentials
404Not FoundProject or file does not existVerify project_id and filename
429Too Many RequestsRate limit exceededRetry with backoff

Examples

cURL

curl "https://markdownapi.io/api/projects/PROJECT_ID/files/article.mdx" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o article.mdx

Python (httpx)

import httpx import os async def download_file(project_id: str, filename: str, output_path: str | None = None): api_key = os.getenv("MARKDOWN_API_KEY") async with httpx.AsyncClient() as client: response = await client.get( f"https://markdownapi.io/api/projects/{project_id}/files/{filename}", headers={"Authorization": f"Bearer {api_key}"}, timeout=60.0 ) response.raise_for_status() content = response.text if output_path: with open(output_path, 'w', encoding='utf-8') as f: f.write(content) print(f"✓ File downloaded: {output_path}") return content

TypeScript

async function downloadFile( projectId: string, filename: string, outputPath?: string ): Promise<string> { const apiKey = process.env.MARKDOWN_API_KEY; const response = await fetch( `https://markdownapi.io/api/projects/${projectId}/files/${filename}`, { headers: { 'Authorization': `Bearer ${apiKey!}` }, } ); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const content = await response.text(); console.log('✓ File downloaded'); return content; }

See Also

Last updated on