Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 908 Bytes

API_DATA.md

File metadata and controls

25 lines (20 loc) · 908 Bytes

API Response Conventions

2017-09-22 - I've messed up quite a bit and a lot of my API responses are all over the place. A lot of them are a bit too specific to views, so this is a doc to write some more consistent API structures.

  1. Instead of returning dictionaries, return list of dictionaries / objects

    • The order is apparent.
    • It gives meta information frequently necessary
result = [
	{
		"key": "key_value",
		"label": "BCAA",
		"value": 55,
		"data_type": "string",
	}
]
  1. Because of #1 never use simple dictionary responses of {k:v}
  2. Use ISO for datetime, never use epoch. Use UTC for all time stamps.
  3. Use "label" as the string to show the display value
  4. Provide data_type so that the frontend has an idea on how to render
  5. Try to generally order them by ascending order (you break this rule in too many places). Put more sort filters so that you can deal with this.