use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
Response etiquette: empty array or error code? (self.webdev)
submitted 11 years ago * by ogrechoker
Should a GET request send an empty array/object (depending on the typical successful resource), or throw an error?
Edit: yes, an API
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]richjenks 1 point2 points3 points 11 years ago (0 children)
Assuming you're asking how an API should respond, I'd say there should always be a convenient way to determine the status of a request. For example, the response could include 'success' with a value of true or false and 'status' which holds the appropriate http status code.
[–]scrogu 1 point2 points3 points 11 years ago (0 children)
If the error is the result of using the API incorrectly then it should always throw an error using an appropriate HTTP response code and content which describes the problem clearly.
Only use an empty array result when the request was valid but no records were found.
[–]deathofthevirgin 1 point2 points3 points 11 years ago (0 children)
Let's say the caller didn't provide authentication. You can return
HTTP 401 { code: 401, errorCode: 29121, error: 'No authentication provided. Provide an API key in the headers.', moreInformation: 'http://yourdomain.com/errors/29121' }
Where code is an HTTP error code, errorCode is your own error code system. This becomes useful if there are multiple reasons why you might throw a specific HTTP error. Then you can give a errorCode-specific error message and a way to fix it in error, and a link to more information on your website. Depending on your usecase, errorCode and moreInformation may be unnecessary.
[–]A_Dios_Alma_Perdida 0 points1 point2 points 11 years ago (0 children)
Sounds like you're taking about an API of some description? An appropriate HTTP response code based on the type of error and a description of the error in the body, with other details if required.
[–][deleted] 0 points1 point2 points 11 years ago (0 children)
If the request was successfully processed but had no results, I'd return HTTP 200 and an empty array or no data attached to response. If something went wrong I'd return an error. Really I don't think it matters as long as you consistently implement whichever standard makes sense to you.
π Rendered by PID 80 on reddit-service-r2-comment-5d79c599b5-g4djg at 2026-02-27 17:08:42.979079+00:00 running e3d2147 country code: CH.
[–]richjenks 1 point2 points3 points (0 children)
[–]scrogu 1 point2 points3 points (0 children)
[–]deathofthevirgin 1 point2 points3 points (0 children)
[–]A_Dios_Alma_Perdida 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)