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

  • SEARCH
  • Home
  • 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 8792887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:02:47+00:00 2026-06-13T23:02:47+00:00

I am building a RESTful API for a web site that allows users to

  • 0

I am building a RESTful API for a web site that allows users to create widgets and tabs containing widgets (think igoogle.com/ netvibes.com) and I want to share my URL design for your insights.

Here are the simple rules:

  1. There is a static list of widgetTypes available for a user to pick.

  2. A user can create one or more widgetInstances of each widgetType.

  3. A user can create one or more tabs/ dashboards containing widgetInstances

This API needs to only serve JSON that will be consumed by JavaScript. We can also assume that all authentication will be taken care of through cookies.

The API needs to serve:

  1. CRUD of user’s Tabs

  2. CRUD of specific user widgetInstances

  3. Retrieval of all tabs for a user

  4. Retrieval of all widgetInstances for a given tab.

  5. Retrieval of all available widgetTypes for a user to add widgets from.

Design:

Tab controller:

widgetAPI.com/tabs -> Returns meta data (id, title) of all tabs available to a user.

widgetAPI.com/tabs/1 -> Returns meta data (title) of tab id 1. If sent with POST, updates tab id 1.

widgetAPI.com/tabs/1/widgets > Returns all widgetInstances of tab id 1.

Question 1: Ideally I’d like to follow the design of widgetAPI.com/tabs/1 also returning all the widgetInstances of the given tab but with that design, widgetAPI.com/tabs may return far too much data as I would have to return all the widgets for all the tabs. Hence I need to create a separate “widgetAPI.com/tabs/1/widgets” URL but that also has to return the tab meta data as I don’t want to make two HTTP calls to get meta data & widgets. Please advise as I am not sure of the best approach here.

widgetAPI.com/tabs/create -> Create a new tab

widgetAPI.com/tabs/delete/123 -> Delete tabid 123

Widget Controller:

widgetAPI.com/widgets/123 -> Return data for widgetInstanceId 123. Updates 123 if sent through POST.

widgetAPI.com/widgets/Create?typeID = 2 -> Creates a new widgetInstance of typeid = 2. This will only be a POST request so typeId could be a post parameter.

widgetAPI.com/widgets/delete/123 -> Delete widgetInstance 123

Question 2 So there is one rule I havent been able to fulfill yet. I need to return all the widgetTypes available and I am not sure how to fit this request into the previous two controllers. I am currently leaning towards just serving this separately. So something like widgetAPI.com/getWidgetTypes. Thoughts?

Thanks guys. If you could critique on the overall design, just address the questions or mention anything I should watch out for, that would be great as this is my first time designing a RESTful app. Thanks again.

  • 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-13T23:02:47+00:00Added an answer on June 13, 2026 at 11:02 pm

    widgetAPI.com/tabs/1 -> Returns meta data (title) of tab id 1. If sent
    with POST, updates tab id 1.

    A POST to the above URL should not update tab 1. A PUT to that URL should update tab 1.

    widgetAPI.com/tabs/create -> Create a new tab

    To create a new tab, you should POST to widgetAPI.com/tabs

    widgetAPI.com/tabs/delete/123 -> Delete tabid 123

    To delete tab 123, send a DELETE to widgetAPI.com/tabs/123

    widgetAPI.com/widgets/123 -> Return data for widgetInstanceId 123. Updates 123 if sent through POST

    To update widget 123, send a PUT to widgetAPI.com/widgets/123

    widgetAPI.com/widgets/Create?typeID = 2 -> Creates a new widgetInstance of typeid = 2. This will only be a POST request so typeId could be a post parameter.

    To create a new widget, send a POST to widgetAPI.com/widgets. The typeId should be part of the POST request body.

    widgetAPI.com/widgets/delete/123 -> Delete widgetInstance 123

    To delete widget 123, send a DELETE request to widgetAPI.com/widgets/123

    Answer 1: I like the widgetAPI.com/tabs/1/widgets URL design. Also, I like the idea of making 2 separate calls for the metadata and the data.

    Answer 2: I think you should do this with a separate controller. I don’t like the URL though. Instead, I like HTTP GET widgetAPI.com/widget-types or just widgetAPI.com/widgettypes.

    As a general rule, unless you want your clients to be able to create URL identifiers, follow this pattern:

    URL: /whatever-resource
    GET – returns all resources of this type
    POST – create a new resource

    URL: /whatever-resource/{id}
    GET – return single resource with that id
    PUT – update resource with that id
    DELETE – delete resource with that id

    You can also allow PUT requests to /whatever-resource/{id} to create a resource, but the client / user must specify the id (implicitly, the URL, since the URL contains the id). If you don’t want users to provide this, but rather have the server generate it, then POST to /whatever-resource to create the resource.

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

Sidebar

Related Questions

I'm building Pylons-based web application with RESTful API, which currently lacks any authentication. So
I'm building a RESTful web api with asp.net mvc, which returns pure json data.
I want to create a webservice that allows users to enter the longitude and
I'm building a RESTful web service that has the usual flavor of CRUD operations
While building a RESTful API of my web service I'm trying to give clients
We're in the process of building an internal, Java-based RESTful web services application that
I'm building out an API for web app that I've been working on for
A Guide to Designing and Building RESTful Web Services with WCF 3.5 , this
I'm building a restful web-service based on Spring. I'm using Spring Security. It will
I am building a RESTful web service in java using JAX-RS and jersey and

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.