modrinth / labrinth

Our Rust-based backend utilizing the actix-web framework to serve Modrinth's API.

Home Page:https://modrinth.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add parameters to pick API response model

falseresync opened this issue · comments

Is your suggested enhancement related to a problem? Please describe.

No response

Describe the solution you'd like

I suggest adding Projections (or otherwise called Models) as described by Spring Data

They could be used in many ways:

  • A projection with only limited data could be used as a protection/authorization measure (which API already presumably does, adding projections en large would just standardize this)
  • API consumers may request less or more expanded projections depending on how much data they need (eg Project vs Search pages)
  • Projections that embed data from other entities could exist

From an API consumer's perspective this could look like so:

  • Requesting an API route with no parameters would return some default projection, likely with authorized-only fields hidden by default
  • Requesting an API route with ?projection=abc parameter would return the specified abc projection with some fields added or removed

One projection I suggest is ?projection=short for Project-related routes, that excludes fields like gallery and description

Describe alternatives you've considered

No response

Additional context

No response