How To Structure Response Data?

60 views
Skip to first unread message

Jay C

unread,
Jan 18, 2016, 9:26:29 AM1/18/16
to API Craft
Hello,

Are there any good resources on how to properly construct response data?

For example, if I POST /emails?to=a...@a.com&from=b...@b.com&subject=test_subject

What should the response look like?

Option 1: Include the original information along with meta data all at 1 level.
{
  "id":1,
  "to":"a...@a.com",
  "from":"b...@b.com",
  "subject":"test_subject",
  "time_sent":"1234567"
}

Option 2: Separate original information and meta data.
{
  "meta": {
      "id":1,
      "time_sent":"1234567"
  },
  "email" : {
      "to":"a...@a.com",
      "from":"b...@b.com",
      "subject":"test_subject"
  }
}


Option 3: Include status with a link.
{
  "status":"success",
  "resource":"/emails/1"
}

Option 4: Something else.

Andrew B

unread,
Jan 18, 2016, 2:41:32 PM1/18/16
to API Craft
SCIM (a much discussed standard of sorts) uses more or less your options 2.

Scroll down to "create request" at http://www.simplecloud.info/.
Message has been deleted

Andrew B

unread,
Jan 18, 2016, 2:43:58 PM1/18/16
to API Craft
Sorry, click "See overview" first.
Reply all
Reply to author
Forward
0 new messages