Unofficial API for SdamGIA educational portal for exam preparation written in Python.
Project description
📚 SdamGIA API
Unofficial API for SdamGIA educational portal for exam preparation written in Python.
⚠️ Important Note
This library retrieves data by parsing HTML because sdamgia uses server-side rendering, which is not very reliable, but the only method available at the moment. We strive to keep the API up to date to work as expected. However, if you encounter any issues, please report them.
Use of this library is at your own risk. Sdamgia explicitly restricts parsing, and we do not take responsibility for any legal issues that arise from using this library.
📦 Installing
Python 3.10 or above is required.
pip
Installing the library with pip
is quite simple:
pip install -U sdamgia
For full problem text recognition support pix2tex
extra is required,
which can be installed like so:
pip install -U "sdamgia[pix2tex]"
poetry
You can add the library as a dependency like so:
poetry add sdamgia
With full text recognition support:
poetry add sdamgia --extras pix2tex
🗂️ Problems database structure
To make it easier to understand how the SdamGIA problems database is structured, I suggest using the following scheme:
SdamGIA
└── GIA type, Subject
├── Problem catalog
│ └── Topic
│ └── Category
│ └── Problem
└── Test
└── Problem
Each problem, test, theme or category has its own unique integer ID.
📃 Documentation
You can find the documentation here.
🚀 Basic usage
Because SdamgiaAPI client is asynchronous, it needs to be initialized in asynchronous context:
import asyncio
import dataclasses
import json
from sdamgia import SdamgiaAPI
from sdamgia.types import Problem
from sdamgia.enums import GiaType, Subject
def problem_to_json(problem: Problem) -> str:
return json.dumps(dataclasses.asdict(problem), indent=4, ensure_ascii=False)
async def main() -> None:
async with SdamgiaAPI(gia_type=GiaType.EGE, subject=Subject.MATH) as sdamgia:
problem_id = 26596
problem = await sdamgia.get_problem(problem_id, subject=Subject.MATH)
print(problem_to_json(problem))
print(problem.url) # https://math-ege.sdamgia.ru/problem?id=26596
if __name__ == "__main__":
asyncio.run(main())
Or without context manager:
from sdamgia import SdamgiaAPI
from sdamgia.enums import GiaType, Subject
async def main() -> None:
sdamgia = SdamgiaAPI(gia_type=GiaType.EGE, subject=Subject.MATH)
# ... do something with client
await sdamgia.close() # this line is mandatory
📜 License
This project is licensed under the LGPLv3+ license - see the license file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sdamgia-0.2.0.tar.gz
.
File metadata
- Download URL: sdamgia-0.2.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.9.3-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
26dd03b54c057ff15c94fda4f2ce06c71241f58d1275696f1e32618378a12af9
|
|
MD5 |
f570c1220896367030dc14fbdb264611
|
|
BLAKE2b-256 |
4faf31639d385384d2860928fde45761dd06286bb792bd88dbe7a77ac5d69962
|
File details
Details for the file sdamgia-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: sdamgia-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.9.3-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
58b7a9672b6da59659fdc0f7aadf28be084653c1d93646891547a2ca4c3b0806
|
|
MD5 |
0bcac78f6de759f4a88537e3e54c659e
|
|
BLAKE2b-256 |
23b4b7fa68f38922f00435eb1ae062844ac4ee01c5192d8da61ebb1187eb7ab5
|