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 :

  1. auth. simple authentification. /api/auth used log system first time , token in response or refresh expired token if required.

  2. 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.

  3. also other methods /api/user/me/orderlist, /api/user/me/someuserspecificinfo.

  4. 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 orders
  • post: create new order

/api/orders/{order-id};

  • get: retrieve info order
  • post: create order specified id
  • put: modify order
  • delete: remove order

putting function-like names in rest api /api/user/neworder great way attract ire of rest fundamentalists.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -