0

I am building a REST API for warehouse inventory picking.

I have a very shallow understanding of REST, so to me that just == stateless and try to make your URL mappings nouns instead of verbs.

The picking process looks like this:

  1. Scan QR on a the shipping instruction sheet which contains an order number along with all SKU's and their quantities. This could be thought of as an aggregate for the entire picking transaction, kicking off the order as "in progress".

  2. Iterate the following steps until all SKUs are picked

    2.a: Scan QR on the physical location being picked from

    2.b: Scan QR on the inventory container at the location

    2.c: Scan QR on the customer label that will be attached to the inventory container

  3. Scan QR on the physical delivery location and drop off the order

Each one of these steps has it's own API endpoint and needs to validate things like

  • Does the order number match the order this user is currently picking?
  • Is this location allowed to be picked from for this order number?
  • Is this a valid inventory container for the order? (SKU not already picked, SKU actually on the order, correct quantity, that sort of thing)
  • Does the SKU on the customer label match the SKU that was previously scanned on the inventory container?

I don't understand how I could create a stateless REST API that meets these requirements. Without state, how do I validate the integrity of every request to make sure the order is being picked correctly?

I had the thought that maybe I'll just have the client pass in the current state of the order on every request (giving me all the data I need to validate a request) but then that assumes I actually trust the client to maintain the correct state, which of course is a bad idea.

Or maybe I could maintain the state of the order on a backend database, and have the client pass me the order number on every request to look it up? This just seems like state with extra steps.

Or maybe I need to move past the idea that this HAS to be a stateless system and break the rules of REST?

Thanks in advance for any advice!

1 Answer 1

1

I don't understand how I could create a stateless REST API that meets these requirements.

Stateless, in the context of REST, means something very specific:

each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server.

It's perfectly normal to have a stateful resource that lives on the server, and to use stateless requests to modify that resource.

maybe I could maintain the state of the order on a backend database, and have the client pass me the order number on every request to look it up? This just seems like state with extra steps.

You certainly can keep your resource state in transient memory; but over the lifetime of a successful project you can anticipate that your process will need to restart at least once, and when that happens you may find the lack of a durable backup of your data... unfortunate.


maybe I need to move past the idea that this HAS to be a stateless system and break the rules of REST?

That's certainly a possibility

REST is intended for long-lived network-based applications that span multiple organizations. If you don’t see a need for the constraints, then don’t use them. -- Fielding, 2008

That said, it looks to me as though the work you are trying to do is a good fit for transfer of documents over a network, so I wouldn't be too quick to give it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.