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 5957475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:24:21+00:00 2026-05-22T18:24:21+00:00

I’m a REST noob trying to design my first REST API schema. Consider a

  • 0

I’m a REST noob trying to design my first REST API schema.

Consider a simple REST API for listing/viewing/editing/deleting user objects. We could use the following 2 URL patterns for routing:

/users          # GET returns a list of users, POST allows creation of new user
/users/{userid} # GET returns user info, PUT for updating user info, DELETE to delete user

So far, so good. Now let’s say that users can be arranged in nestable folders. So a user could now be inside a folder, and a folder can contain both users and sub-folders. To allow management of folders, we want to add the following functions to our API:

  • List contents (users and sub-folders) of a folder
  • Create a new folder
  • Rename, delete folders
  • Move a user or sub-folder to a different parent folder

What is the best way of providing this functionality in a REST API? I came up with two ideas:

Idea 1: Show folder hierarchy in URL

e.g. /users/folder1/folder2/chris

At first glance this looks nice, but there are a number of problems with this approach:

  • Both users and folders now have the same URL pattern. It’s impossible to know whether /users/a/b/c points to a user or a folder. This makes for a difficult to understand API, and an annoying implementation involving manual parsing of URLs and guesswork.

  • When the client sends a POST to /users/folder1 we don’t know whether they want to create a new user or a new sub-folder. They will have to specify in the request body. Again this leads to an annoying server-side implementation, and does not seem very RESTful.

  • No obvious way to allow moving of resources from one folder to another

Idea 2: Add parent folder info to resource

Keep the simple 2 URL patterns shown above, and add a parentFolder field to the user resource.

e.g. a GET to /users may return (in JSON):

{'users': 
   [{'name':'chris','DoB':'1/1/1900','parentFolder':'/folder1/folder2'},
   ...]
}

Add separate URL pattern /folders and /folders/{folderid} for viewing/editing/deleting folders.

This solves some of the problems with Idea 1, but in terms of design it makes me uneasy:

  • Adding a resource’s parent as an attribute of the resource seems strange.

  • Why do we have to separate users and their folders into separate APIs, even though they are so obviously inter-related?

Thanks for reading this far. Are they are any better ways of dealing with this?

  • 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-05-22T18:24:21+00:00Added an answer on May 22, 2026 at 6:24 pm

    There is definitely nothing strange about adding a link to your user resource to identify the containing folder. RESTful design is 95% about adding links between resources and 5% about deciding on what the URI looks like.

    Doing a POST to /users/a/b/c with either a user resource or a folder resource should not cause you concern. One of the major advantages of doing RESTful HTTP is that you are not constrained by the limits of RPC. We are used to procedure calls that statically define what are the input parameters and the output parameters. HTTP has headers fields like Content-Type that allow input and output parameters to be defined at runtime.

    I believe you are correct that option #2 will likely be easier to dispatch on the server than option #1. However, as long as you avoid URI construction on the client by using the server to return all the links the client might need, either option should be fine for your client.

    Moving users around can be as simple as POSTing a user to a new folder and letting the server figure out if it needs to remove the user from the old folder.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.