Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:59:29+00:00 2026-06-03T11:59:29+00:00

Consider a user (/users/{id}) which has a name and multiple locations (/users/{id}/locations). When I

  • 0

Consider a user (/users/{id}) which has a name and multiple locations (/users/{id}/locations).

When I request a user (/user/{id}), should that user be represented fully–its id, name and locations–or should locations only be returned on a separate request? For example, which JSON DTO would you expect on a request for user with id=123 (/users/123):

1) { “id”:123, “name”:”Peter”, “locations”:[{“id”:1, “name”:”Chicago”}, {“id”:2, “name”:”New York”}] }

2) { “id”:123, “name”:”Peter”, “locations”:[{“id”:1}, {“id”:2}] }

3) { “id”:123, “name”:”Peter”, “locations”:[1, 2] }

4) { “id”:123, “name”:”Peter” }

Is this more subjective, pushing and pulling between size of the DTOs and requests required in the typical use-case? I’m inclined to simply include all of the relevant data (1), but I’m not certain that’s better than just requiring developers to make multiple calls to an API to get all of the data they actually want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:59:31+00:00Added an answer on June 3, 2026 at 11:59 am

    To be RESTful you don’t necessarily have to return the full representation of the resource
    You do however want to enable hypermedia as means to get/set all the information the user of your API needs (Hypermedia as the engine of application state – a.k.a. HATEOAS)

    To satisfy that you can either use the suggestion by @bowmanb to put a URI for all the locations or add individual URIs for each of the locations. You probably want to add additional URIs for other options of doing something with the resource.

    There’s a good article on HATEOAS by Jim Webber, Savas Parastatidis & Ian Robinson called “how to GET a cup of coffee”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider one has some user defined types, and containers of those types that are
Consider a Name model which has a required label attribute and an arbitrary Rails
Consider a type bar which has user-defined conversion operators to references of type bar
Consider the following tables: users and tweets user_id name tweet_id user_id tweet spam -----------------
Consider a model user: User(id: integer, name: string, email: string, status: string) When I
Consider this: class User < ActiveRecord::Base # name, email, password end class Article <
I've a developer which has given users the ability to download a zip archive
In Nerddinner project, i see that dinners has relation to users by username if
I have a very typical situation. We have a table called Users which has
Please consider this scenario: a web app that has 4 levels of access: admin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.