1

I have the following problem. Please suggest me the inputs.

I require the list of transactions which can be categorized as

a. Pending/Completed

b. For given account numbers

c. For given customer ids

d. For given categories (category A, Category B) and so on.

Any of these 4 above and all of these are optional.

I am thinking of putting the above 4 options as query param and have a url something like this http://localhost:8080/Transaction/?status=pending&customerid=3,4&category=catA

Is this a Good design for this requirement?

[EDIT] I do not know if it is good design to pass nouns as query parameters.

3
  • Clarification : Are you going to pass more than one accounts numbers and more than one customer ids and more than one categories at the same time? Commented Oct 8, 2013 at 9:11
  • Yes. It is possible to pass more than one. But status will be only one always either pending or completed. Commented Oct 8, 2013 at 9:13
  • 1
    It looks eminently reasonable to me. Your resource is a Transaction, and so it is in the path. You are trying to retrieve from all Transactions, with a particular subset of properties. Commented Oct 8, 2013 at 9:16

1 Answer 1

1

As per as REST URI design is concerned, you have to find out the resources first then operations and how they are linked to each other.

Moreover you should use nouns in your URIs, and try to minimize the number of the query parameters.

For this scenario, you basically want to search for transaction based on some conditions, as you have mentioned.

http://localhost:8080/transaction?status=pending&customerid=3,4&category=catA 

You are right, but the implementation should split the value of query parameters to extract values.

In a general practice, Consumer,Account can be treated as separate resource.

http://localhost:8080/consumer/{consumerId}/account/{accountNumber}/transaction?status=pending 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.