Skip to content

RESTful API Documentation

Nick Petosa edited this page Apr 26, 2017 · 10 revisions

GET requests

ALL_USERS get

Fetch an array of all User objects.

Headers

  • type = ALL_USERS

Response

All User objects in a JSON list.

Example Request

POST  HTTP/1.1
Host: 127.0.0.1:8000
type: ALL_USERS

Example Response

[
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": 732592954,
			"uuid": "16.732592954"
		},
		"name": "Satya Nadella",
		"creation": {
			"date": "Apr 26, 2017 5:41:07 PM",
			"unix_date": 1493242867545
		}
	},
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": -1782484030,
			"uuid": "16.2512483266"
		},
		"name": "George P. Burdell",
		"creation": {
			"date": "Apr 26, 2017 5:39:08 PM",
			"unix_date": 1493242748383
		}
	}
]

GET_USERS get

Fetch an array of User objects given their UUIDs.

Headers

  • type = GET_USERS
  • uuids = [list, of, uuids]

Response

User objects in a JSON list. If a provided UUID does not map to a user, it does not contribute to the response array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: GET_USERS
uuids: [16.732592954]

Example Response

[
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": 732592954,
			"uuid": "16.732592954"
		},
		"name": "Satya Nadella",
		"creation": {
			"date": "Apr 26, 2017 5:41:07 PM",
			"unix_date": 1493242867545
		}
	}
]

GET_CONVERSATIONS get

Fetch an array of Conversation objects given their UUIDs.

Headers

  • type = GET_CONVERSATIONS
  • uuids = [list, of, uuids]

Response

Conversation objects in a JSON list. If a provided UUID does not map to a conversation, it does not contribute to the response array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: GET_CONVERSATIONS
uuids: [16.3020133850]

Example Response

[
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": -1274833446,
			"uuid": "16.3020133850"
		},
		"owner": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": -1782484030,
			"uuid": "16.2512483266"
		},
		"creation": {
			"date": "Apr 26, 2017 5:43:48 PM",
			"unix_date": 1493243028040
		},
		"title": "Georgia Tech",
		"users": [],
		"firstMessage": {
			"id": 0,
			"uuid": "0"
		},
		"lastMessage": {
			"id": 0,
			"uuid": "0"
		}
	}
]

FIND_CONVERSATIONS get

Fetch an array of Conversation objects given a regex pattern to match their titles.

Headers

  • type = FIND_CONVERSATIONS
  • filter = some regex pattern as string

Response

Matching Conversation objects in a JSON list. If the filter does not match, you will receive an empty array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: FIND_CONVERSATIONS
filter: .*soft.*

Example Response

[
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": -436886707,
			"uuid": "16.3858080589"
		},
		"owner": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": 732592954,
			"uuid": "16.732592954"
		},
		"creation": {
			"date": "Apr 26, 2017 5:53:54 PM",
			"unix_date": 1493243634409
		},
		"title": "Microsoft",
		"users": [],
		"firstMessage": {
			"id": 0,
			"uuid": "0"
		},
		"lastMessage": {
			"id": 0,
			"uuid": "0"
		}
	}
]

TIMED_CONVERSATIONS get

Fetch an array of Conversation objects created between a given date range.

Headers

  • type = TIMED_CONVERSATIONS
  • from = earliest creation date, provided as a Unix time stamp in milliseconds.
  • to = latest creation date, provided as a Unix time stamp in milliseconds.

Response

Matching Conversation objects in a JSON list. If no conversations were created in the given time frame, you will receive an empty array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: FIND_CONVERSATIONS
from: 1493243810000
to: 1493243851526

GET_MESSAGES get

Fetch an array of Message objects given their UUIDs.

Headers

  • type = GET_MESSAGES
  • uuids = [list, of, uuids]

Response

Message objects in a JSON list. If a provided UUID does not map to a message, it does not contribute to the response array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: GET_MESSAGES
uuids: [16.2305306822]

Example Response

[
	{
		"id": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": -1989660474,
			"uuid": "16.2305306822"
		},
		"previous": {
			"id": 0,
			"uuid": "0"
		},
		"creation": {
			"date": "Apr 26, 2017 6:02:55 PM",
			"unix_date": 1493244175713
		},
		"author": {
			"root": {
				"id": 16,
				"uuid": "16"
			},
			"id": 732592954,
			"uuid": "16.732592954"
		},
		"content": "Why doesn't Steve Ballmer let me ride the elevator with him?",
		"next": {
			"id": 0,
			"uuid": "0"
		}
	}
]

TIMED_MESSAGES get

Fetch an array of Conversation objects created between a given date range.

Headers

  • type = TIMED_MESSAGES
  • conversation = UUID.as.string (The conversation to insert this message into)
  • from = earliest creation date, provided as a Unix time stamp in milliseconds.
  • to = latest creation date, provided as a Unix time stamp in milliseconds.

Response

Matching Message objects in a JSON list. If no messages were created in the given time frame, you will receive an empty array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: TIMED_MESSAGES
conversation: 16.3858080589
from: 1493243810000
to: 1493243851526

RANGED_MESSAGES get

Fetch an array of Message objects which are chained together.

Headers

  • type = RANGED_MESSAGES
  • root_message = UUID.as.string, the message to start at during traversal.
  • range = int, the number of steps to take on the chain for inclusion in results. If this number is negative, traversal occurs backwards in the chain.

Response

Matching Conversation objects in a JSON list. If no conversations were created in the given time frame, you will receive an empty array.

Example Request

GET  HTTP/1.1
Host: 127.0.0.1:8000
type: RANGED_MESSAGES
root_message: 16.2305306822
range: -5

POST requests

NEW_USER post

Adds a new user to the server.

Headers

  • type = NEW_USER

Body

The username you want to register as a raw body.

Response

The new User object in JSON.

Example Request

POST  HTTP/1.1
Host: 127.0.0.1:8000
type: NEW_USER

George P. Burdell

Example Response

{
	"id": {
		"root": {
			"id": 16,
			"uuid": "16"
		},
		"id": -1782484030,
		"uuid": "16.2512483266"
	},
	"name": "George P. Burdell",
	"creation": {
		"date": "Apr 26, 2017 5:39:08 PM",
		"unix_date": 1493242748383
	}
}

NEW_CONVERSATION post

Adds a new conversation to the server.

Headers

  • type = NEW_CONVERSATION
  • owner = UUID.as.string

Body

The title of the conversation you want to create as a raw body.

Response

The new Conversation object in JSON.

Example Request

POST  HTTP/1.1
Host: 127.0.0.1:8000
type: NEW_CONVERSATION
owner: 16.2512483266

Georgia Tech

Example Response

{
	"id": {
		"root": {
			"id": 16,
			"uuid": "16"
		},
		"id": -1274833446,
		"uuid": "16.3020133850"
	},
	"owner": {
		"root": {
			"id": 16,
			"uuid": "16"
		},
		"id": -1782484030,
		"uuid": "16.2512483266"
	},
	"creation": {
		"date": "Apr 26, 2017 5:43:48 PM",
		"unix_date": 1493243028040
	},
	"title": "Georgia Tech",
	"users": [],
	"firstMessage": {
		"id": 0,
		"uuid": "0"
	},
	"lastMessage": {
		"id": 0,
		"uuid": "0"
	}
}

NEW_MESSAGE post

Adds a new message to the server.

Headers

  • type = NEW_MESSAGE
  • author = UUID.as.string
  • conversation = UUID.as.string

Body

The content of the message you want to create as a raw body.

Response

The new Message object in JSON.

Example Request

POST  HTTP/1.1
Host: 127.0.0.1:8000
type: NEW_MESSAGE
author: 16.732592954
conversation: 16.3858080589

Why doesn't Steve Ballmer let me ride the elevator with him?

Example Response

{
	"id": {
		"root": {
			"id": 16,
			"uuid": "16"
		},
		"id": -1989660474,
		"uuid": "16.2305306822"
	},
	"previous": {
		"id": 0,
		"uuid": "0"
	},
	"creation": {
		"date": "Apr 26, 2017 6:02:55 PM",
		"unix_date": 1493244175713
	},
	"author": {
		"root": {
			"id": 16,
			"uuid": "16"
		},
		"id": 732592954,
		"uuid": "16.732592954"
	},
	"content": "Why doesn't Steve Ballmer let me ride the elevator with him?",
	"next": {
		"id": 0,
		"uuid": "0"
	}
}