Python endpoint discovery

    List Django REST Framework Endpoints and Nested URL Patterns

    Django exposes a runtime URL resolver, while Django REST Framework routers generate patterns for registered viewsets. A useful inventory has to recurse through included URLconfs, preserve prefixes, and separate API endpoints from admin, static, and non-API views.

    Direct framework method

    Start with the routes registered at runtime

    Walk Django's root URL resolver recursively after settings and application initialization. DRF router patterns appear in that tree, but the resolver output still needs filtering and method-level context before it becomes a useful API inventory.

    Django REST Framework route inventory · python
    from django.urls import URLPattern, URLResolver, get_resolver
    
    def list_url_patterns(
        patterns: list[URLPattern | URLResolver],
        prefix: str,
    ) -> list[str]:
        routes: list[str] = []
        for pattern in patterns:
            route = prefix + str(pattern.pattern)
            if isinstance(pattern, URLResolver):
                routes.extend(list_url_patterns(pattern.url_patterns, route))
            else:
                routes.append(route)
        return routes
    
    for route in list_url_patterns(get_resolver().url_patterns, ""):
        print(route)

    Where a route-listing snippet stops

    • Django settings and application imports must initialize successfully before the resolver is available.
    • The URL tree includes admin, static, health, and regular web views unless you classify them explicitly.
    • A URL pattern alone does not reliably expose every allowed HTTP method, serializer, permission, or authentication requirement.
    • Dynamically selected URLconfs and deployment-specific settings can produce different runtime inventories.

    Use source as the second inventory

    APIScout analyzes supported Django and Django REST Framework projects from source in VS Code, connects routes with implementation context, and creates an OpenAPI baseline without booting the application.

    Review supported frameworks

    Turn the inventory into a reviewable API contract

    Export OpenAPI, review the endpoints with the team that owns them, and use the same contract for documentation and security testing.

    Open the source-to-OpenAPI workflow