Skip to content

martenmatrix/stine-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STiNE Logo

⚠️ This project is far from stable and may contain many bugs and cause unexpected behavior.

A STiNE API Wrapper

This is an unofficial STiNE API for Go. It is easy to use, completely request-based and uses no browser automation, which makes it incredible fast.

Table of Contents

✨ Features

Done

  • ✅ User Auth
  • ✅ Fetch categories available for user
  • ✅ Fetch modules available for user
  • ✅ Register user for a module
  • ✅ Change language

TODOS

  • ❎ Fetch schedules for a user
  • ❎ Register user for a lecture
  • ❎ Register user for an exercise
  • ❎ Get information about the user
  • ❎ Get messages
  • ❎ Download documents
  • ❎ Start applications
  • ❎ Use contact form
  • ❎ Get exam results for the user
  • ❎ Get exam results for the user by using the mobile STiNE API Endpoint (results show up earlier)

📎 Examples

Authenticate a user

// Authenticate user
session := NewSession()
err := session.Login("BBB????", "password")

if err != nil {
    fmt.Println("Authentication failed")
}

// Session is now authenticated
fmt.Println(session.SessionNo) // returns e.g. 631332205304636

Fetch categories and modules available for user

// Session should be authenticated
session := NewSession()

initialCategory, err := session.GetCategories(1)

// Print title of every category reachable from first category
for _, category := range initialCategory.Categories {
    fmt.Println(category.Title)
}

vssModule := initialCategory.Categories[0].Modules[1] // select "Distributed Systems and Systems Security (SuSe 23)" module located at second place in first listed category

fmt.Println(vssModule.Title)   // Distributed Systems and Systems Security (SuSe 23)
fmt.Println(vssModule.Teacher) // Prof. Dr. Name Surname

firstEvent := vssModule.Events[0]

fmt.Println(fmt.Printf("Available places: %f", firstEvent.MaxCapacity))   // print places available
fmt.Println(fmt.Printf("Booked places : %f", firstEvent.CurrentCapacity)) // print places already booked

// Refresh everything listed under initialCategory.Categories[0]
// Only works on categories, all modules within a category will be refreshed
firstCategoryRefresh, err := initialCategory.Categories[0].Refresh(0)
if err != nil {
    // Handle error
}

// Check e.g., if places became available
fmt.Println(firstCategoryRefresh)

Register user for a module

// Session should be authenticated
session := NewSession()

// Module ideally should be retrieved with GetCategories
vssModule := moduleGetter.Module{}

// Create module registration
moduleRegistration := session.RegisterForModule(vssModule)
moduleRegistration.SetExamDate(1)            // Select second available exam date
tanReq, err := moduleRegistration.Register() // Send registration to servers

if err != nil {
    // Handle error
}

if tanReq != nil {
    // iTAN is required for registration
    fmt.Println(tanReq.TanStartsWith) // Print starting numbers of itan e.g. 087
    err := tanReq.SetTan("087233233") // We can also enter the tan without prefix e.g. 233233
    
    if err != nil {
        // Handle error
    }
}

// User is registered for the module and maybe also registered for the exam, sometimes you are only able to select an exam after joining the lecture

Change Language for user

// Session should be authenticated
session := NewSession()

err := session.ChangeLanguage("de")

if err != nil {
    // Handle error
}

// Language is set to German

err = session.ChangeLanguage("en")

if err != nil {
    // Handle error
}

// Language is set to English

🚀 Installation

Execute the following line in your Go project:

GOPROXY=direct go get github.com/martenmatrix/stine-api/cmd

and import it with

import "github.com/martenmatrix/stine-api/cmd"

📚 Documentation

The documentation can be found here or you can generate it on your local computer with godoc -http=:6060.

📜 License

MIT

About

Easily interact with STiNE in Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages