0

I’m developing an API for multimedia service. In database I have media table which stores different media (movies, music, series etc). There’re two types of users: admins and users.

Users can access media using different endpoints:

  • /movies
  • /cartoons
  • /music
  • /series
    • /seasons
      • /episodes
  • etc.

Each endpoint returns only data specific for media type. Each endpoint has specific search arguments.

API for admins will not be public. Is it normal create single endpoint to control media types? For example, I can create /media endpoint which will be used to CRUD different media types.

Should I separate API for admins and API for users in different projects?

How should I handle situations when resource has different fields for admins and users?

Katomi
  • 25
  • 4

1 Answers1

0

How should I handle situations when resource has different fields for admins and users?

Should I separate API for admins and API for users in different projects?

Probably. It may help to keep in mind that resources "adapt" your domain model for the web -- they are an integration concern.

The web is not your domain, it's a document management system. All the HTTP verbs apply to the document management domain. URIs do NOT map onto domain objects - that violates encapsulation. Work (ex: issuing commands to the domain model) is a side effect of managing resources. In other words, the resources are part of the anti-corruption layer. You should expect to have many many more resources in your integration domain than you do business objects in your business domain -- Jim Webber

Community
  • 1
  • 1
VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91