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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:35:27+00:00 2026-05-22T17:35:27+00:00

How to structure an API where the same data may request in different format,

  • 0

How to structure an API where the same data may request in different format, in a RESTful format. For example.

GET /person/<id>  //get the details of resource <id>

Now depending on the client (browser) requirement, the data may send as html (say normal rendering) or Json (say ajax call). So my doubts are

  1. Can I keep the same url for both requests, or should keep them seperate?
  2. How to detect whether the request is for html/Json at the server. The request type is same (GET). So which parameter should I consider.
  3. How to detect the difference in data type at client (html/Json)\

thanks,

bsr.

  • 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-22T17:35:27+00:00Added an answer on May 22, 2026 at 5:35 pm

    Similar question: REST Content-Type: Should it be based on extension or Accept header?

    The accepted answers has great points.

    Can I keep the same url for both requests, or should keep them seperate?

    Yes, keep them the same. Its the same resource, you’re just asking for different representations of it.

    How to detect whether the request is for html/Json at the server. The request type is same (GET). So which parameter should I consider.

    You can use the Accept header to specify the return content-type.

    How to detect the difference in data type at client (html/Json)\

    You would look at the “Content-Type” header.

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

Sidebar

Related Questions

I'm porting our old Active-Record based API over to a new structure to make
SICP - Structure and Interpretation of Computer Programs Explanation for the same would be
I want a data structure that will allow querying how many items in last
I have a data structure whose operations can be categorized as read operations (e.g.
We are trying to implement a REST API for an application we have now.
g++ 4.4.3 I have the following structure from a API guide: typedef struct NETWORK_INFO
I have the following site structure Parent Site -> blog (wordpress) -> get-recent-posts.php ->
So I'm trying to document the format of the json returned by an api
Our application is structured something like: UI <--> REST API <--> Workflow <--> Business
I have a tree structure in memory that I would like to render in

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.