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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:39:05+00:00 2026-06-05T21:39:05+00:00

I am designing a restful HTTP API for my application. The app has Categories

  • 0

I am designing a restful HTTP API for my application.

The app has Categories which have Products.

I want the users to be able to create a product within a category, and if that category doesn’t exist, then it would be created automatically. So there would be no API for creating the category separately (since I don’t want people to create categories without any products).

I don’t quite get how I should design the API for this. The usual way would be:

1. Create a category:
   POST /categories {"name": "Movies"}
2. Use the new category's id to create a product:
   POST /categories/:id/products {"name": "The Matrix"}

Since I don’t want to expose the first one to the users, how should I let them create the product directly?

  • 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-05T21:39:06+00:00Added an answer on June 5, 2026 at 9:39 pm

    Products should probably not be a subordinate resource to categories. Just create the new product with a list of categories that it belongs to, then use the /categories resource to browse the categories. New categories are added as a side effect when a new one appears in a product’s category list.

    1. Create product:
    PUT /product/the_matrix {"name":"The Matrix","category_list":["movies","science fiction"]}
    
    2. Browse categories:
    GET /categories
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing a Restful HTTP API and have a design question. In my
I am designing a RESTful API for a booking application and was quite happy
I am designing an RESTful API for our product and have encountered the need
I'm designing a RESTful API that currently has resources that include some elements that
I am designing a RESTful API and am using the usual HTTP status codes
Designing my RESTful API, I would like use following URI http://[HOST]/[PLANET]/[LAT];[LONG] e.g. http://myserver/earth/50.2;29.1 What
We're designing the URL structure for our web app and want to use RESTful,
I am designing RESTful Api's and would like some advice on designing an API
I am designing a RESTful API and I would like to know what the
I'm currently (I try to) designing a RESTful API for a social network. But

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.