# StudentVue API
![travis](https://travis-ci.org/kajchang/StudentVue.svg?branch=master)
![PyPI version](https://badge.fury.io/py/studentvue.svg)

This repository provides a easy way to access data from StudentVue portals in Python programs.

Note:

If this library isn't updating properly, try explictly installing the latest version (e.g. `pip3 install studentvue==1.2.1`) to fix this issue in the future.

## Logging In

`pip install studentvue` or clone / download the repository and `python setup.py install`.

```python
from studentvue import StudentVue
sv = StudentVue('username', 'password', 'domain name') 
```

## Basic API

```python
classes = sv.get_classes()
"""
[
    'Period 2 CCSS Algebra 2A Taught by XXX XXX in Room XXX with a Grade of XX.X%',
    'Period 3 Chemistry A H Taught by XXX XXX in Room XXX with a Grade of XX.X%',
    ...
    'Period 7 AP Euro Hist A Taught by XXX XXX in Room XXX with a Grade of XX.X%',
    'Period 8 PE 2A Taught by XXX XXX in Room XXX with a Grade of XX.X%'
]
"""

# classes and teachers are both objects

print(classes[0].room) # XXX

print(classes[0].teacher.email) # XXX@XXX.XXX
```

```python
sv.get_student_info()
"""
{
    'Student Name': 'XXXXX',
    'Student No': 'XXXXXX',
    'Gender': 'Male',
    'Grade': '10'
}
"""
```

```python
sv.get_school_info()
# Principal, if supplied, will also be converted to a Teacher object
"""
{
    'Principal': Andrew Ishibashi,
    'School Name': 'Lowell HS',
    'Address': '1101 Eucalyptus DrSan Francisco, CA 94132',
    'Phone': '415-759-2730',
    'Fax': '415-759-2742',
    'Website URL': 'https://lhs-sfusd-ca.schoolloop.com/'
}
"""
```

```python
with open('school_picture.png', 'wb') as school_picture_file:
  sv.get_image(school_picture_file)
```

## Bugs and Contributing

The content and formatting of pages may vary from district to district, so the same parsing strategies might fail. If you find an instance of this, or have a general improvement you can [raise a new issue](https://github.com/kajchang/StudentVue/issues/new) and/or [open a pull request](https://github.com/kajchang/StudentVue/compare).

## TODO

- Finish Scraper

- Write tests
