tonyzimbinski / infinite-campus

📚 unofficial API for Infinite Campus written in Node JS
GNU General Public License v3.0
29 stars 11 forks source link

Custom instance support? #8

Closed trentwiles closed 3 years ago

trentwiles commented 3 years ago

My district uses a self hosted instance of Infinite Campus, is this project compatible with that?

qwazwsx commented 3 years ago

hmm... It might be. If you can find your district login page through this link then you should be good to go. If not, let me know and I'll see what I can do.

The API works like this:

  1. we use your provided district & state info to search for your where your districts I.C instance is located. This search uses the url I sent above. So if you can't find your district with that search tool, this API won't work out-of-the-box.
  2. after we get your district's I.C. URL, we log in using your credentials
  3. after logging in, we can make authenticated requests to retrieve classes, grades or whatever you want

So, let me know if you can find your district with the search tool above, if not I can update the API so you can skip step #1 and just specify your I.C URL directly.

look forward to hearing from you

qwazwsx commented 3 years ago

I explained how it works much better in #7

trentwiles commented 3 years ago

I actually tried it out and it works fine. I'm not sure about how exactly setting up a IC instance works, but I believe they are all linked into a central database and when a user picks their district on the main site, they are forwarded to the correct instance (like you said).

Very interesting and useful project, only thing I could recommend is to add an option for a more "realistic" user agent in case IC starts blocking/flagging services like this in the future (ie. Mozilla/5.0 (X11; CrOS x86_64 13729.56.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.95 Safari/537.36)

qwazwsx commented 3 years ago

Glad everything worked out!

Interesting point about the user agent string. I was conflicted about this when I wrote it. Since it's a completely unofficial API running on servers that aren't mine I wanted to err on the side of caution and identify the API with a GitHub link and version number. That way I.C. sysadmins could contact me or easily temporarily block the API if there were any issues. I'm not sure about recent versions of I.C, but they used to have an access log that showed a log of the user agents that logged in. So I thought it'd be nice to be transparent about who/what was logging in as well. However, like you said, it does also mean they could flag these requests and block all of them if they dont like the idea of people using their public API in an unauthorized way. However, if that ever happens I can always update the user agent string to cycle thru some more realistic strings. Haven't had any issues so far, though.

trentwiles commented 3 years ago

Thanks for the response, I'll be sure to build something neat with this.

qwazwsx commented 3 years ago

Good luck! Let me know what you build :)