Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cristiangrojas/9e6fe95409862397f50cd0cd4899fabb to your computer and use it in GitHub Desktop.
Save cristiangrojas/9e6fe95409862397f50cd0cd4899fabb to your computer and use it in GitHub Desktop.
# Tavtrac API Docs
## Login
Post user credentials in to Login endpoint to get `auth_token` data. the user is required to be `School Admin`.
With the auth_token data, you must send that token in the [HTTP Authorization request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) with this sintax
**Example**
```Javascript
"Authorization": "Token {auth_token}"
```
* **URL**
`auth/login/`
* **Method**
`POST`
* **Url Params**
None
* **Query Params**
**Required:**
`authenticated_user_role: [string] = SchoolAdmin`
* **Data Params**
**Required:**
`username: [string] = "username"`
`password: [string] = "password"`
* **Success Response**
* Code: 200
Content:
```javascript
{
"url": "http://sda-v2:8000/v1/accounts/users/5061/",
"id": 5061,
"parent_profile": ...,
"student_profile": ...,
"group_manager_profile": ...,
"bus_manager_profile": ...,
"scheduler_profile": ...,
"school_admin_profile": ...,
"profile_picture_square_small": ...,
"profile_picture_square_medium": ...,
"auth_token": "6ef25bbb6e555613b6de475b83582de7090406b6",
"email": ...,
"username": ...,
"first_name": ...,
"last_name": ...,
"profile_picture": ...,
"gender": ...,
"phone": ...,
"mobile_phone": ...,
"address": ...,
"is_active": ...,
"has_parent_profile": ...,
"has_student_profile": ...,
"has_scheduler_profile": ...,
"has_group_manager_profile": ...,
"has_bus_manager_profile": ...,
"has_school_admin_profile": ...
}
```
* **Error Response**
* Code: 400
Content:
```javascript
{
"non_field_errors": [
"Unable to login with provided credentials."
]
}
```
## Get all the parent of a school
* **URL**
`v1/accounts/users/`
* **Method**
`GET`
* **Url Params**
None
* **Query Params**
**Required:**
`has_parent_profile: [boolean] = True`
`parent_profile__schools__id: [integer]= :schoolId`
**Optional:**
`fields: [string] = 'url,first_name,parent_profile,children,is_active'`
`children__as: [string] = 'nested'`
`guardians__as: [string] = 'nested'`
`is_parent_for_school: [string] = :schoolId`
*To limit the response*
`limit: [integer] = 20`
`offset: [integer] = 0`
* **Data Params**
None
* **Success Response**
* Code: 200
Content:
```javascript
{
"count": 938,
"next": "http://sda-v2:8000/v1/accounts/users/?children__as=nested&fields=url%2Cfirst_name%2Clast_name%2Cparent_profile%2Cchildren%2Cis_active&has_parent_profile=True&limit=20&offset=20&parent_profile__schools__id=2",
"previous": null,
"results": [
{
"url": "http://sda-v2:8000/v1/accounts/users/140/",
"parent_profile": {
"url": "http://sda-v2:8000/v1/accounts/profiles/parents/50/",
"id": 50,
"children": [
{
"id": 470,
"username": "tnunes1",
"first_name": "Tim",
"last_name": "Nunes",
"relationship": "mother",
"has_custody": false,
"grade": {
"id": 29,
"name": "1"
}
}
],
"additional_adult_schools": [],
"ir_id": null,
"last_email_notification_datetime": "2017-05-18T17:38:40.137025Z",
"source_id": null,
"source_id_without_prefix": null,
"user": "http://sda-v2:8000/v1/accounts/users/140/",
"schools": [
"http://sda-v2:8000/v1/schools/schools/2/",
"http://sda-v2:8000/v1/schools/schools/5/",
"http://sda-v2:8000/v1/schools/schools/6/"
],
"branches": [
"http://sda-v2:8000/v1/schools/branches/6/",
"http://sda-v2:8000/v1/schools/branches/7/"
]
},
"first_name": "Paul",
"last_name": "McDonough",
"is_active": true
}
]
}
```
## Get all the students of a school
Returns json data about a multiple users with student profile.
* **URL**
`v1/accounts/users/`
* **Method**
`GET`
* **Url Params**
None
* **Query Params**
**Required:**
`has_student_profile: [boolean] = True`
`student_profile__school_id: [integer]= :schoolId`
**Optional:**
`fields: [string] = 'url,first_name,student_profile,is_active'`
`student_profile__fields: [string] = 'url,grade'`
`student_profile__grade__as: [string] = 'nested'`
`parent__as: [string] = 'nested'`
`guardians__as: [string] = 'nested'`
*To limit the response*
`limit: [integer] = 20`
`offset: [integer] = 0`
* **Data Params**
None
* **Success Response**
* Code: 200
Content:
```javascript
{
"count": 728,
"next": "http://sda-v2:8000/v1/accounts/users/?fields=url%2Cfirst_name%2Clast_name%2Cstudent_profile%2Cis_active&has_student_profile=True&limit=20&offset=20&ordering=last_name&student_profile__fields=url%2Cgrade%2Chas_guardians%2Cguardians&student_profile__school_id=2",
"previous": null,
"results": [
{
"url": "http://sda-v2:8000/v1/accounts/users/1536/",
"student_profile": {
"url": "http://sda-v2:8000/v1/accounts/profiles/students/1674/",
"guardians": "http://sda-v2:8000/v1/accounts/profiles/student-guardians/?student_profile_id=1674&parent__as=nested",
"has_guardians": true,
"grade": "http://sda-v2:8000/v1/schools/grades/4/"
},
"first_name": "Eric",
"is_active": true
},
...
]
}
```
* **Error Response**
* Code: 401
Content:
```javascript
{
"detail": "Authentication credentials were not provided."
}
```
* Code 400
Content:
```javascript
{
"detail": "school {schoolId} no is allowed "
}
```
## Get de daily attendance reports
* **URL**
`v1/schools/activities/reports/student-daily-attendance-reports-v2/`
* **Method**
`GET`
* **Url Params**
None
* **Query Params**
**Required:**
`student__student_profile__school: [integer] = :schoolId`
**Optional:**
`activity__id: [integer] = :activityId`
*To limit the response*
`limit: [integer] = 20`
`offset: [integer] = 0`
* **Data Params**
None
* **Success Response**
* Code: 200
Content:
```javascript
{
"count": 393,
"next": "http://sda-v2:8000/v1/schools/activities/reports/student-daily-attendance-reports-v2/?limit=20&offset=20&student__student_profile__school=2",
"previous": null,
"results": [
{
"url": "http://sda-v2:8000/v1/schools/activities/reports/student-daily-attendance-reports-v2/225/",
"id": 225,
"attendance_code_other_reason": "",
"arrival_time": null,
"departure_time": null,
"date": "2016-10-07",
"comment": "",
"created": "2016-10-07T14:12:20.136572Z",
"modified": "2017-02-13T16:22:53.126584Z",
"reported_by": "http://sda-v2:8000/v1/accounts/users/157/",
"student": "http://sda-v2:8000/v1/accounts/users/15/",
"attendance_code": "http://sda-v2:8000/v1/schools/attendance-codes/attendance-codes/1/",
"attendance_code_reason": "http://sda-v2:8000/v1/schools/attendance-codes/attendance-codes-reasons/2/",
"pickup_responsible": null
},
...
]
}
```
## Get student at school check in
* **URL**
`v1/schools/events/students-at-the-school-check/`
* **Method**
`GET`
* **Url Params**
None
* **Query Params**
**Required:**
`school_id: [integer] = :schoolId`
**Optional:**
`date: [date(%Y-%m-%d)] = 2017-06-08`
*To limit the response*
`limit: [integer] = 20`
`offset: [integer] = 0`
* **Data Params**
None
* **Success Response**
* Code: 200
Content:
```javascript
{
"count": 9396,
"next": "http://sda-v2:8000/v1/schools/events/students-at-the-school-check/?limit=20&offset=20&school_id=2",
"previous": null,
"results": [
{
"url": "http://sda-v2:8000/v1/schools/events/students-at-the-school-check-in-out/2865/",
"id": 2865,
"comment": "",
"type": "absent",
"event_type": "day-attendance",
"undoed": false,
"created_from": null,
"triggered_by": null,
"date": "2017-02-27",
"time_override": null,
"created": "2017-02-27T20:13:58.593062Z",
"modified": "2017-02-27T20:13:58.593080Z",
"school": "http://sda-v2:8000/v1/schools/schools/2/",
"branch": "http://sda-v2:8000/v1/schools/branches/2/",
"student": "http://sda-v2:8000/v1/accounts/users/55/",
"reported_by": "http://sda-v2:8000/v1/accounts/users/1401/",
"activity": "http://sda-v2:8000/v1/schools/activities/activities/567/",
"trigger_object": null
},
...
]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment