Hot answers tagged

22 votes
Accepted

REST API to list books, where null means "everything"

I personally think it's fine, but it helps to turn your thinking around from a "selector" to a "filter". Then, the default is to return all books, and you selectively filter down the set you're going ...
14 votes
Accepted

ASP.NET REST controller with try-catch error handling

throw ex; This is a fatal mistake. It'll create a new stack-trace and you won't be able to tell where the actual exception occured. If you want to rethrow it then ...
  • 43.9k
9 votes

Spring Boot RESTful service

Should be changed: Request mappings are not that RESTful due to the verbs: POST /api/cars/add-car => POST /api/cars ...
9 votes

Star Wars API GET request in Python

This is pretty good. I only have a few small nitpicks Return directly You do this a few times: ...
  • 11.4k
7 votes

Tracking Containers in a Train Station

...
  • 22.2k
7 votes

Tracking Containers in a Train Station

I'm really sorry, but after starting this review I have to tell you: Go back, read some more tutorials and try again This code has so many issues, that I'm not able to point them out reasonably ...
  • 25.1k
7 votes
Accepted

A PHP API which has an endpoint for processing a user's facebook login details

A lot of times people post PHP here and it's often very ugly, this is not one of those times. Your classes and design are beautiful, and it's very obvious what your intentions are. You've built a ...
7 votes

Build a set of REST interfaces using Symfony framework

I'll try to cover the response part. SingleProduct and BundleProduct should be polymorphic. ...
  • 486
7 votes
Accepted

Generic method to call API functions with simple retrial on errors

Inversion-of-control I wouldn't use reflection using error-prone member-by-string lookup, when a simple Func provides type-safe behavior. This signature could be ...
  • 13.8k
6 votes
Accepted

RESTEasy client that should use generics

I managed to get RESTEasy to work with generics (both lists and single objects) and parse the response to JAXB annotated classes by using the following code that uses reflection: ...
  • 593
6 votes

Registration, login and logout in a Grails application

Disclaimer: I don't know sqat about Grails createUser I have a few concerns in this method. Using User.countByEmail seems ...
  • 110k
6 votes

Basic API wrapper around a Restful service

I would personally prefer to use HttpClient directly as it provides full control and perfect testability - see here. We can define our REST API as: ...
  • 6,133
6 votes
Accepted

Bitex - Cryptocurrency Exchange API Framework for Python

There's a lot of code here, so I'm just going to review bitex.utils. You'll see that there's plenty here for one review. Maybe some of the other reviewers here at ...
  • 49.3k
6 votes
Accepted

Mini HttpClient json post by Action parameter

Great job. Here are some minor notes though. In newer versions of C# you can leverage async Main in order not to wait for your test method. ...
6 votes

HttpClient reusable instance for simple calls on another methods

Dispose Strategy It seems your class doesn't even need to implement IDisposable. Should dispose HttpClient? Single Responsibility I would extract configuration ...
  • 13.8k
6 votes
Accepted

Rest Api with generic crud operations

Your code is good, but some improvements could be made. Here are my suggestions: Use lowercase for first letter of variable. Example: BrandService BrandService; ...
6 votes
Accepted

Testable REST API Client

You require the interface to be IDisposable which is a bit of a shame. You're only doing this so that you can dispose of the HttpClient, but as it says in the ...
6 votes

Spring boot application web service

fizzBuzzOutputsRepo is an in-memory map and there is no data persistence. So if the web server crashes, then there will be data loss. Even if data persistence is ...
  • 306
6 votes
Accepted

Using Node.js, Express, and Express Router to implement a very simple REST API

After I examine the codes you have written, I could see some things that are not rightly done. Below are the few things I highlighted: The structuring of the codebase is not okay hence it can be ...
6 votes

Auctionsite API Wrapper in Python

In API.__init__, you're assigning a value to self.base_url. However, that value is never changed and thus is the same for every ...
5 votes
Accepted

Controller for classrooms and students

The actions I'm wondering about are members, add_student, and remove_student. They work just fine, but they aren't RESTful [...] True, they're not part the usual CRUD actions that can be expressed ...
  • 32.9k
5 votes
Accepted

Small console app to execute some remote scripts

Welcome to the wonderful world of F#! You're doing fine so far! You'll find that the code stops being quite so awkward as you get more experienced. Meanwhile, here are my comments: Type ...
  • 501
5 votes
Accepted

REST API using PHP

Instead of: $_SERVER['REQUEST_URI'] REQUEST_URI: index.php/products/xxx/yyy Use: ...
5 votes
Accepted

Single class which holds response and error message

Is that error, or status, or both, or neither? This API is a bit confusing. You have ErrorCode and StatusCode enums. But ...
  • 110k
5 votes

Python wrapper class around HTTP API

You're right, you can cut down on the repetition of code. Although bundling all of the functions into one like you mention would work, you lose a bit of the readability that keeping them as class ...
  • 158
5 votes
Accepted

Library to be used against a specific REST web service

Creating a session As a library, I find it barely usable. If I want to use it with my own credentials, I have to: either modify the source of your library to put them in ...
5 votes

Python Stock Checker

Your code looks hard to read and not like Python code. The main reason for this is that every second line is a comment. Most of these comments just repeat what the surrounding code does. These ...
5 votes
Accepted

Restful CRUD API with Node.js and Express

I know you are generating data for the sake of completion but it does complicate things on what aspect of the code you'd like to focus on. But here are a couple thoughts. With Express, I often like ...
  • 316
5 votes

ASP.NET REST controller with try-catch error handling

Typically in an ASP.NET app (and in fact in any app), you should only catch and handle the base System.Exception in a single place as close to the application entry ...
  • 948
5 votes
Accepted

Simple CRUD back-end for an inventory-tracking web API

Disclaimer: there will be a lot of links to my own site because I am helping people with PHP for 20+ years and got an obsession with writing articles about most common issues. I don't know much ...

Only top scored, non community-wiki answers of a minimum length are eligible