api.py 744 B

123456789101112131415
  1. from wagtail.api.v2.router import WagtailAPIRouter
  2. from wagtail.api.v2.views import PagesAPIViewSet
  3. from wagtail.documents.api.v2.views import DocumentsAPIViewSet
  4. from wagtail.images.api.v2.views import ImagesAPIViewSet
  5. # Create the router. "wagtailapi" is the URL namespace
  6. api_router = WagtailAPIRouter("wagtailapi")
  7. # Add the three endpoints using the "register_endpoint" method.
  8. # The first parameter is the name of the endpoint (eg. pages, images). This
  9. # is used in the URL of the endpoint
  10. # The second parameter is the endpoint class that handles the requests
  11. api_router.register_endpoint("pages", PagesAPIViewSet)
  12. api_router.register_endpoint("images", ImagesAPIViewSet)
  13. api_router.register_endpoint("documents", DocumentsAPIViewSet)