ellite / Wallos

Wallos: Open-Source Personal Subscription Tracker
GNU General Public License v3.0
3.03k stars 139 forks source link

API docs / automated backup #498

Open saschabrockel opened 2 months ago

saschabrockel commented 2 months ago

I want to automate my backups for your amazing app. I tried it with curl -O http://192.168.178.21:8282/endpoints/db/backup.php for example but I also need to be authenticated and I cannot create a token that easily like that.

It would be very nice to have documentation of the API or even better an integrated mechanism to auto backup on schedule and leave only x updates there or of the last 4 weeks.

ellite commented 2 months ago

I'll have a look into this when I have some time.

latetedemelon commented 5 days ago

Please take this with a grain of salt, I guarantee nothing :)

openapi: 3.0.0
info:
  title: Wallos Internal API
  description: API documentation for Wallos's internal endpoints.
  version: 1.0.0
servers:
  - url: http://localhost
    description: Local server
paths:
  /login.php:
    post:
      summary: User login
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                username:
                  type: string
                password:
                  type: string
              required:
                - username
                - password
      responses:
        '200':
          description: Successful login; redirects to the dashboard.
        '401':
          description: Invalid credentials; displays an error message.
      security: []
  /registration.php:
    post:
      summary: User registration
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                username:
                  type: string
                email:
                  type: string
                  format: email
                password:
                  type: string
                currency:
                  type: string
              required:
                - username
                - email
                - password
                - currency
      responses:
        '201':
          description: Successful registration; redirects to the login page.
        '400':
          description: Missing or invalid parameters; displays an error message.
      security: []
  /passwordreset.php:
    post:
      summary: Password reset
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
              required:
                - email
      responses:
        '200':
          description: Password reset email sent; displays a confirmation message.
        '404':
          description: Email not associated with any account; displays an error message.
      security: []
  /verifyemail.php:
    get:
      summary: Email verification
      parameters:
        - name: email
          in: query
          required: true
          schema:
            type: string
            format: email
        - name: verification_code
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Email successfully verified; redirects to the login page.
        '400':
          description: Invalid verification code; displays an error message.
      security: []
  /logout.php:
    get:
      summary: User logout
      responses:
        '200':
          description: Successful logout; redirects to the login page.
      security:
        - sessionAuth: []
  /api/subscriptions.php:
    get:
      summary: Retrieve subscriptions
      responses:
        '200':
          description: Returns a JSON array of subscriptions.
        '401':
          description: User not authenticated; returns an error message.
      security:
        - sessionAuth: []
    post:
      summary: Create a new subscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                amount:
                  type: number
                currency:
                  type: string
                category_id:
                  type: integer
                billing_cycle:
                  type: string
                next_payment_date:
                  type: string
                  format: date
              required:
                - name
                - amount
                - currency
                - category_id
                - billing_cycle
                - next_payment_date
      responses:
        '201':
          description: Subscription successfully created; returns the subscription ID.
        '400':
          description: Missing or invalid parameters; returns an error message.
        '401':
          description: User not authenticated; returns an error message.
      security:
        - sessionAuth: []
    put:
      summary: Update an existing subscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                name:
                  type: string
                amount:
                  type: number
                currency:
                  type: string
                category_id:
                  type: integer
                billing_cycle:
                  type: string
                next_payment_date:
                  type: string
                  format: date
              required:
                - id
      responses:
        '200':
          description: Subscription successfully updated; returns the updated subscription data.
        '400':
          description: Missing or invalid parameters; returns an error message.
        '401':
          description: User not authenticated; returns an error message.
        '404':
          description: Subscription not found; returns an error message.
      security:
        - sessionAuth: []
    delete:
      summary: Delete a subscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
              required:
                - id
      responses:
        '200':
          description: Subscription successfully deleted; returns a confirmation message.
        '400':
          description: Missing or invalid parameters; returns an error message.
        '401':
          description: User not authenticated; returns an error message.
        '404':
          description: Subscription not found; returns an error message.
      security:
        - sessionAuth: []
  /api/categories.php:
    get:
      summary: Retrieve categories
      responses:
        '200':
          description: Returns a JSON array of categories.
        '401':
          description: User not authenticated; returns an error message.
      security:
        - sessionAuth: []
    post:
      summary: Create a new category
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
              required:
                - name
      responses:
        '201':
          description: Category successfully created; returns the category ID.
        '400':
          description: Missing or invalid parameters; returns an error message.
        '401':
          description: User not authenticated; returns an error message.
      security:
        - sessionAuth: []
    put:
      summary: Update an existing category
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                name:
                  type: string
                description:
                  type: string
              required:
                - id
      responses:
        '200':
          description: Category successfully updated; returns the updated category data.
        '400':
          description: Missing or invalid parameters; returns an error message.
        '401':
          description: User not authenticated; returns an error message.
        '404':
          description: Category not found; returns an error message.
      security:
        - sessionAuth: []
    delete:
      summary: Delete a category
      requestBody:

::contentReference[oaicite:0]{index=0}
latetedemelon commented 5 days ago

@saschabrockel - I think you need to authenticate first, then attempt a backup.

--> login.php POST: (application/x-www-form-urlencoded): username (string): User's username. password (string): User's password.

latetedemelon commented 5 days ago