curl -X POST "http://localhost:8001/wiki/generate" \
  -H "Content-Type: application/json" \
  -d '{
    "repo_url": "https://github.com/microsoft/TypeScript-Node-Starter",
    "model_provider": "google",
    "model_name": "gemini-2.0-flash",
    "force_regenerate": false
  }'
{
  "success": true,
  "wiki_id": "wiki_1234567890",
  "repo_info": {
    "url": "https://github.com/microsoft/TypeScript-Node-Starter",
    "name": "TypeScript-Node-Starter",
    "owner": "microsoft",
    "platform": "github"
  },
  "generation_status": "completed",
  "wiki_pages": [
    {
      "id": "overview",
      "title": "Project Overview", 
      "content": "TypeScript Node Starter is...",
      "importance": "high",
      "filePaths": ["README.md", "package.json"],
      "relatedPages": ["setup", "architecture"]
    }
  ],
  "metadata": {
    "generated_at": "2024-01-15T10:30:00Z",
    "model_used": "gemini-2.0-flash",
    "processing_time": 45.2,
    "total_files_analyzed": 127
  }
}
The DeepWiki-Open API provides programmatic access to all wiki generation and repository analysis features. Built with FastAPI, it offers high-performance endpoints for integration into your development workflows.

API Base URL

For production deployments, replace with your actual API server URL.

API Architecture

The DeepWiki API is organized into several key areas:

Quick Start

Authentication

Most endpoints require authentication via environment-configured API keys. The API validates your configured providers automatically.
curl -X GET "http://localhost:8001/health"

Basic Wiki Generation

curl -X POST "http://localhost:8001/wiki/generate" \
  -H "Content-Type: application/json" \
  -d '{
    "repo_url": "https://github.com/microsoft/TypeScript-Node-Starter",
    "model_provider": "google",
    "model_name": "gemini-2.0-flash",
    "force_regenerate": false
  }'
{
  "success": true,
  "wiki_id": "wiki_1234567890",
  "repo_info": {
    "url": "https://github.com/microsoft/TypeScript-Node-Starter",
    "name": "TypeScript-Node-Starter",
    "owner": "microsoft",
    "platform": "github"
  },
  "generation_status": "completed",
  "wiki_pages": [
    {
      "id": "overview",
      "title": "Project Overview", 
      "content": "TypeScript Node Starter is...",
      "importance": "high",
      "filePaths": ["README.md", "package.json"],
      "relatedPages": ["setup", "architecture"]
    }
  ],
  "metadata": {
    "generated_at": "2024-01-15T10:30:00Z",
    "model_used": "gemini-2.0-flash",
    "processing_time": 45.2,
    "total_files_analyzed": 127
  }
}

Core Endpoints

Wiki Generation

Chat & RAG

Model Configuration

Data Models

WikiPage

id
string
required
Unique identifier for the wiki page
title
string
required
Human-readable page title
content
string
required
Full page content in Markdown format with Mermaid diagrams
filePaths
array
required
Source file paths that contributed to this page
importance
string
required
Page importance level: high, medium, or low
Array of related page IDs for cross-references

RepoInfo

url
string
required
Full repository URL
name
string
required
Repository name
owner
string
required
Repository owner/organization
platform
string
required
Git platform: github, gitlab, or bitbucket
private
boolean
Whether the repository is private
default_branch
string
Default branch name (usually main or master)

Error Handling

The API uses standard HTTP status codes and returns detailed error information:
{
  "error": {
    "code": "INVALID_REPOSITORY",
    "message": "Repository not found or not accessible",
    "details": {
      "repo_url": "https://github.com/invalid/repo",
      "status_code": 404,
      "suggestion": "Verify the repository URL and access permissions"
    },
    "timestamp": "2024-01-15T10:30:00Z"
  }
}

Common Error Codes

Rate Limits

Rate limits depend on your AI provider’s limits. DeepWiki doesn’t impose additional rate limits.

Provider Rate Limits

  • GPT-4: 500 requests/minute, 30,000 tokens/minute
  • GPT-3.5: 3,500 requests/minute, 90,000 tokens/minute
  • Varies by usage tier and model

WebSocket API

For real-time updates during wiki generation and chat:
const ws = new WebSocket('ws://localhost:8001/ws/wiki/generate');

ws.onopen = () => {
  ws.send(JSON.stringify({
    repo_url: 'https://github.com/microsoft/vscode',
    model_provider: 'google',
    model_name: 'gemini-2.0-flash'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  
  switch(data.type) {
    case 'progress':
      console.log(`Progress: ${data.progress}%`);
      break;
    case 'page_generated':
      console.log(`Generated page: ${data.page.title}`);
      break;
    case 'completed':
      console.log('Wiki generation completed!');
      break;
    case 'error':
      console.error('Error:', data.error);
      break;
  }
};

SDK Examples

Python SDK Usage

import asyncio
import aiohttp
import json

class DeepWikiClient:
    def __init__(self, base_url="http://localhost:8001"):
        self.base_url = base_url
    
    async def generate_wiki(self, repo_url, model_provider="google", 
                          model_name="gemini-2.0-flash"):
        async with aiohttp.ClientSession() as session:
            payload = {
                "repo_url": repo_url,
                "model_provider": model_provider,
                "model_name": model_name
            }
            
            async with session.post(
                f"{self.base_url}/wiki/generate",
                json=payload
            ) as response:
                return await response.json()
    
    async def ask_question(self, question, repo_url):
        async with aiohttp.ClientSession() as session:
            payload = {
                "message": question,
                "repo_url": repo_url
            }
            
            async with session.post(
                f"{self.base_url}/chat/stream",
                json=payload
            ) as response:
                async for line in response.content:
                    yield json.loads(line.decode())

# Usage
async def main():
    client = DeepWikiClient()
    
    # Generate wiki
    wiki = await client.generate_wiki(
        "https://github.com/fastapi/fastapi"
    )
    print(f"Generated {len(wiki['wiki_pages'])} pages")
    
    # Ask questions
    async for response in client.ask_question(
        "How does FastAPI handle dependency injection?",
        "https://github.com/fastapi/fastapi"
    ):
        print(response['content'], end='', flush=True)

asyncio.run(main())

Node.js SDK Usage

class DeepWikiClient {
  constructor(baseUrl = 'http://localhost:8001') {
    this.baseUrl = baseUrl;
  }

  async generateWiki(repoUrl, options = {}) {
    const {
      modelProvider = 'google',
      modelName = 'gemini-2.0-flash',
      forceRegenerate = false
    } = options;

    const response = await fetch(`${this.baseUrl}/wiki/generate`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        repo_url: repoUrl,
        model_provider: modelProvider,
        model_name: modelName,
        force_regenerate: forceRegenerate
      })
    });

    if (!response.ok) {
      throw new Error(`API Error: ${response.status}`);
    }

    return await response.json();
  }

  async *askQuestion(question, repoUrl) {
    const response = await fetch(`${this.baseUrl}/chat/stream`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        message: question,
        repo_url: repoUrl
      })
    });

    const reader = response.body.getReader();
    const decoder = new TextDecoder();

    while (true) {
      const { done, value } = await reader.read();
      if (done) break;

      const chunk = decoder.decode(value);
      const lines = chunk.split('\n').filter(line => line.trim());
      
      for (const line of lines) {
        if (line.startsWith('data: ')) {
          try {
            yield JSON.parse(line.slice(6));
          } catch (e) {
            console.warn('Failed to parse SSE data:', line);
          }
        }
      }
    }
  }
}

// Usage
const client = new DeepWikiClient();

async function example() {
  try {
    // Generate wiki
    const wiki = await client.generateWiki(
      'https://github.com/expressjs/express'
    );
    console.log(`Generated ${wiki.wiki_pages.length} pages`);

    // Ask question with streaming response
    console.log('\nAsking question...');
    for await (const chunk of client.askQuestion(
      'Explain Express.js middleware system',
      'https://github.com/expressjs/express'
    )) {
      if (chunk.type === 'content') {
        process.stdout.write(chunk.content);
      }
    }
  } catch (error) {
    console.error('Error:', error.message);
  }
}

example();

Next Steps