php - Profile/account REST API naming convention -
i have tried search net, haven't found example of best practice url naming convention following requests.
api allows user log system, retrieve secure token can used access private data on https.
so there following features support api :
auth. simple authentification.
/api/auth
used log system first time , token in response or refresh expired token if required.view profile data (first name,last name, phone number ....). best way form url resource. have several ideas :
/api/users/me/profile or /api/users/{id}/profile
. in first case our client (rest api consumer) doesn't need know exact id of user, when user tries access resource checks if token valid,if passed user name exists , tied token, , returns data based on information. in second case have know exact id of user, of course id can returned in response auth.also other methods
/api/user/me/orderlist, /api/user/me/someuserspecificinfo
.what making order. have read if need create new resource have use post, if update - put. how url should ?
/api/neworder (parameters in post body), /api/user/neworder , /api/orders (just post method)
.......
please suggest commonly used naming convention such resources
your resource uris should more or less constant, , http verb determines action performed, eg:
/api/orders
:
get
: list orderspost
: create new order
/api/orders/{order-id}
;
get
: retrieve info orderpost
: create order specified idput
: modify orderdelete
: remove order
putting function-like names in rest api /api/user/neworder
great way attract ire of rest fundamentalists.
Comments
Post a Comment