简体   繁体   中英

Building REST API - separate requests

I am building an API and am a little unsure whether it would be better to have a request that brings back all information relating to a resource, or just bring back info separately according to tasks that need carrying out. For example, I have a messages resource and am struggling to decide whether to bring back all message information in one go. OR have a separate request for unread messages, a separate request for a list of messages and another request for a single message.

What is the proper way? I am tempted to keep them all separate but then worrya bout having to do too many requests.

Stop worrying and just do .

I like to keep things separate in the beginning, and at some point, I realise that request x always followed by request y , so I'll just merge those two. You won't know what you'll need until you're working on it...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM