Sobes.tech
Senior

Design an API for generating a bank statement (PDF document, which takes a long time to generate). What endpoints are needed?

sobes.tech AI

Answer from AI

For the API generating bank statements, considering that PDF generation can take a long time, it is recommended to use an asynchronous approach with multiple endpoints:

  1. POST /statements/generate

    • Request to create a new statement.
    • The request body includes parameters: period, account, filters, etc.
    • Returns a unique statementId and a status of "processing".
  2. GET /statements/{statementId}/status

    • Check the status of the statement generation.
    • Returns status: "processing", "ready", "error".
  3. GET /statements/{statementId}/download

    • Download the ready PDF.
    • Returns the file if the status is "ready".
  4. DELETE /statements/{statementId} (optional)

    • Delete the generated statement to free up space.

This approach allows the client not to wait for the generation to complete, but to poll the status and download the file when it is ready.

Design an API for generating a bank statement (PDF… - sobes.tech