How to specify a resource id when the unique id is made up of multiple pieces of data?

83 views
Skip to first unread message

Mandy Warren

unread,
Mar 13, 2013, 1:20:54 PM3/13/13
to api-...@googlegroups.com
Hi I am wondering about how best to representative a resource id when the id is unique only through a combination of items. For example, a bank account may only be unique with the combo of account number plus sort code. I could specify:

/accounts/someHashOfTheAcctNumPlusSortCode

or

/accounts?accountnumber=123456&sort=121230

The downside of the 2nd option would be if I wanted to access a subresource of the account eg the last 20 transactions as the query params for the different resources get mixed together.

/accounts/transactions/accountnumber=123456&sort=121230&max=20

(please note this is only an analogy, I don't work in banking!)

Any help gratefully received!

Thanks
Mandy

Ian Joyce

unread,
Mar 13, 2013, 2:22:42 PM3/13/13
to api-...@googlegroups.com
I would consider something like /accounts/{account-number}-{sort} or /accounts/{accountNumber}/{sort}


Mandy

--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Phil Jackson

unread,
Mar 14, 2013, 9:06:42 AM3/14/13
to api-...@googlegroups.com
Hey Mandy,

If sort code were meta data of an account then another option might be
to use:

/account/123456?sortcode=121230

It doesn't really work in the banking example but it might for your
real world scenario.

Cheers,
Phil
--
Apiaxle http://apiaxle.com - A free, open proxy for your API.

Mandy Warren

unread,
Mar 14, 2013, 6:46:13 PM3/14/13
to API Craft

Thanks Ian and Phil. I think I prefer Phil's approach but having read
more about matrix params I would prefer to use:

accounts/123456;sortcode=121230

So that I could do something like:

accounts/123456;sortcode=121230/transactions?orderby=alpha

to specify to return me all the transactions for the specified account
ordered alphabetically. Matrix params would refer to a particular
resource and the query param would refer to filtering of the
responses.

I will post a separate post about matrix param usage as I am keen to
see how people use these in real life.

Mandy
> Apiaxlehttp://apiaxle.com- A free, open proxy for your API.
Reply all
Reply to author
Forward
0 new messages