NOTES/LEGEND - parameter=value means value is the confirmed value of that parameter - ¶meter means parameter is optional - ¶meter=default means parameter is optional and defaults to specified default - parameter(format) means parameter has specific type or format besides string - On error, all requests to `api/*` return an error code and this object: { "message": "Some message about the error type" "uri": ":some_path" } Where the message specifies the nature of the error and the URI is the path accessed (`:host/api/:some_path` - :host is usually http://p2p.anuv.me) REST API ENDPOINTS api GET/POST/PUT/DELETE Body: (null) Returns: message auth POST Body: { username(case-insensitive, alphanumeric), password(alphanumeric) } Returns: { token, data: { id, username, fullname, type } } GET AUTH Body: (null) Returns: { data: { id, username, fullname, type } } students create Body: { username(alphanumeric), password(alphanumeric), fullname(alphanumeric except space, dash, comma, period) } Returns: { token, data: (student_object){ id, username, fullname, profile=null, type=student } } :student_id GET AUTH Body: (null) Returns: (student_object){ id, username, fullname, profile, type=student } tutors GET AUTH Body: { lat(float), long(float), subjects(CSV), &latrange(float)=null, &longrange(float)=null, &range(float)=25 } Returns: [ tutor1(tutor_object), tutor2(tutor_object), ... ] create Body: { username(alphanumeric), password(alphanumeric), fullname(alphanumeric except space, dash, comma, period), school(alphanumeric except space, dash, comma, period, parentheses), bio, subjects(CSV, alphanumeric except space, dash, comma, period, parentheses), city(alphanumeric except space, dash, comma, period) } Returns: { token, data: (tutor_object){ id, username, fullname, school, bio, subjects(CSV), stars(float/null)=null, hours(int)=0, city, location: [ lat(float/null), long(float/null) ], distance, profile=null, type=tutor } } :tutor_id GET AUTH Body: { &reviewData=false } Returns: (tutor_object){ id, username, fullname, school, bio, subjects(CSV), stars(float/null), hours(int), city, location: [ lat(float/null), long(float/null) ], profile, type=tutor, &reviews: (if reviewData==true)[ review1(review_object), review2(review_object), ... ] } reviews GET AUTH Body: (null) Returns: [ review1(review_object), review2(review_object), ... ] create POST AUTH Body: { stars(float), text } Returns: (review_object){ id, from, stars, text, created(ISO8601_date) } :review_id GET AUTH Body: (null) Returns: (review_object){ id, from, stars, text, created(ISO8601_date) } hours POST AUTH Body: { hours(int), &add(bool)=false } Returns: { hours } GET AUTH Body: (null) Returns: { hours } location POST AUTH Body: { lat(float/null), long(float/null) } Returns: { lat(float/null), long(float/null) } GET AUTH Body: (null) Returns: { lat(float/null), long(float/null) } sessions GET AUTH Body: { &studentData=false, &tutorData=true } Returns: [ session1(session_object), session2(session_object), ... ] create POST AUTH Body: { student(student_id, alphanumeric), tutor(tutor_id, alphanumeric), lat(-90 < float < 90), long(-180 < float < 180) } Returns: (session_object){ id, student, tutor, location: [ lat(float), long(float) ], created(ISO8601_date), state="pending" } :session_id GET AUTH (only student or tutor from session) Body: { &studentData=false, &tutorData=true } Returns: (session_object){ id, location: [ lat(float), long(float) ], student(student_object (if studentData==true, else) student_id), tutor(tutor_object (if tutorData==true, else) tutor_id), created(ISO8601_date), state="pending" or "confirmed" or "commenced" or "completed" or "cancelled" } location POST AUTH (only student from session) Body: { lat(-90 < float < 90), long(-180 < float < 180) } Returns: { lat(float/null), long(float/null) } GET AUTH (only student or tutor from session) Body: (null) Returns: { lat(float/null), long(float/null) } state POST AUTH (only student or tutor from session) Body: { action="confirm" (only tutor from session) or "commence" (only student from session) or "complete" (only student from session) or "cancel" } GET AUTH (only student or tutor from session) Body: (null) Returns: { state="pending" or "confirmed" or "commenced" or "completed" or "cancelled" } images upload POST AUTH Body: { profile(image/png) } Returns: { message, image(URI) } :user_id GET Body: null Returns: { image(image/png) }