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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:54:57+00:00 2026-06-02T21:54:57+00:00

I’m trying to make an API sorta loosly based on StackExchange’s api results. So

  • 0

I’m trying to make an API sorta loosly based on StackExchange’s api results.

So here’s my json output.

{
    "items" : [ ... objects in here .... ]
    "page" : 
    "page_size" :  
    "total_pages" : 
    "total_items_count" :  
    "maximum_quota" : 
    "remaining_quota" : 
}

pretty damn simple.

Now, I’m not sure what do to if the person tries to request a .. um .. product or question or whatever, and the item doesn’t exist.

eg..

{
    "items": []
    ... snipped ....
}

I was thinking I would return a 200 AND the Json above, with the Items property being empty.

The other idea I had was returning that json with the items property empty BUT setting the response http status to 404.

Thoughts / standards ?

I really want to return the json no matter what. Why? the quota’s. Even an empty result is still a legit hit to the api service.

  • 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-02T21:54:57+00:00Added an answer on June 2, 2026 at 9:54 pm

    In my opinion I would return a 400 & 204 status:

    http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

    400 Bad Request

    The request cannot be fulfilled due to bad syntax.[2]

    If you pass an invalid argument, a 400 status is returned saying the request is bad.

    In this scenario, I wouldn’t return any JSON message back. It’s invalid, sort it out. The StatusMessage can say ‘Invalid Argument’, but no content.


    204 No Content

    The server successfully processed the request, but is not returning any content.[2]

    If you pass valid arguments, but the content wasn’t found, you can say it wasn’t found.

    You may* want to pass some additional info back, may not.

    For Twitter, say you wanted to search for ‘@JohnDoe’ user, and it wasn’t found. You could say 204, with: “Sorry we couldn’t find @JohnDoe, but we did find these 3 similar people that may be what you want” in which case you wouldn’t push down their details, just the Twitter names.

    However if you were searching for a tweet, and it wasn’t found, there’s no reason to send any additional info to the client. Just say it wasn’t found, end of story.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.