Files
huso/README.md
daru 89c65c29e8 API DOC 🎉
2022-05-18 23:55:35 +02:00

254 lines
7.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# huso
Hanami's universeller Serien Organizer
**Backend code**
## API
### General
| Method | Route | Response |
| - | - | - |
| GET | / | Startseite als HTML |
| GET | /api/log | Log als plaintext |
### Auth
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/auth/{user} | Test für Authentifizierung | (status code) | {user} = MAL username | X-HUSO-AUTH | |
| POST | /api/register | Registrieren | RegisterData JSON | | | RegisterData JSON |
| DELETE | /api/register | User löschen | RegisterData JSON | | | RegisterData JSON |
_RegisterData_
```json
{
"username": "TESTUSERNAME",
"malId": 42069,
"secret": "1ef539ed34435873fc964c2c20da84f8793ae3731a154cffb41039f2f061cabe97dea18cfffa51c58f3f564f8e7f0cd0a98d7ba3dddb7301c0e7549626ea43af",
"sauce": "31f3637d8d05ddca7deee89453e3b68a9b74860facd8d5a6768e5ca842571595c8d31e43ce0e996f893578d0bd2b61f3f3820ec03fbb30407e31a2603c887b1"
}
```
_sauce_
```
SHA512(綾波レイ + malId + username)
```
_secret_
```
SHA512(SAUCE + PASSWORD)
```
_X-HUSO-AUTH_ -> _secret_ des users
### Anime
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/season | Aktuelle Season holen | []Anime JSON | | | |
| GET | /api/anime/{id} | Einzelnen Anime holen | Anime JSON | {id} = MAL Anime id | | |
| GET | /api/animesearch | Anime auf MAL suchen | []Anime JSON | Query parameter {q} = Suchtext | | |
_[]Anime_
```json
[
{
"anime": 50265,
"title": "Spy x Family",
"titleEn": "",
"titleJp": "SPY×FAMILY",
"imageMedium": "https://cdn.myanimelist.net/images/anime/1441/122795.jpg",
"imageLarge": "https://cdn.myanimelist.net/images/anime/1441/122795l.jpg",
"imageThumb": "https://cdn.myanimelist.net/images/anime/1441/122795t.jpg",
"url": "https://myanimelist.net/anime/50265",
"type": "TV",
"status": "Currently Airing",
"episodes": 12,
"synopsis": "ANYA~ [Written by MAL Rewrite]",
"genres": [
{
"id": 1,
"name": "Action"
},
{
"id": 4,
"name": "Comedy"
}
],
"startDate": "2022-04-09T00:00:00Z",
"endDate": "0001-01-01T00:00:00Z",
"year": 2022,
"season": "spring",
"score": 9.07,
"scoredBy": 191073,
"rank": 5,
"popularity": 239,
"members": 661291,
"source": "Manga",
"weekday": "Saturdays",
"studios": [
{
"id": 858,
"name": "Wit Studio"
},
{
"id": 1835,
"name": "CloverWorks"
}
],
"trailerUrl": "https://www.youtube.com/watch?v=ofXigq9aIpo",
"trailerEmbedUrl": "https://www.youtube.com/embed/ofXigq9aIpo?enablejsapi=1&wmode=opaque&autoplay=1"
},
{
"anime": 43608,
"title": "Kaguya-sama wa Kokurasetai: Ultra Romantic",
"titleEn": "Kaguya-sama: Love is War - Ultra Romantic",
"titleJp": "かぐや様は告らせたい-ウルトラロマンティック-",
"imageMedium": "https://cdn.myanimelist.net/images/anime/1160/122627.jpg",
"imageLarge": "https://cdn.myanimelist.net/images/anime/1160/122627l.jpg",
"imageThumb": "https://cdn.myanimelist.net/images/anime/1160/122627t.jpg",
"url": "https://myanimelist.net/anime/43608",
"type": "TV",
"status": "Currently Airing",
"episodes": 12,
"synopsis": "Tsun [Written by MAL Rewrite]",
"genres": [
{
"id": 4,
"name": "Comedy"
},
{
"id": 41,
"name": "Suspense"
}
],
"startDate": "2022-04-09T00:00:00Z",
"endDate": "0001-01-01T00:00:00Z",
"year": 2022,
"season": "spring",
"score": 8.99,
"scoredBy": 74937,
"rank": 13,
"popularity": 396,
"members": 454326,
"source": "Manga",
"weekday": "Saturdays",
"studios": [
{
"id": 56,
"name": "A-1 Pictures"
}
],
"trailerUrl": "https://www.youtube.com/watch?v=vFN5K-iAyV0",
"trailerEmbedUrl": "https://www.youtube.com/embed/vFN5K-iAyV0?enablejsapi=1&wmode=opaque&autoplay=1"
}
]
```
### User
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/user/{user?} | MAL user suchen oder alle registrierten user holen | []User JSON | {user?} = optional: MAL username | | |
_[]User_
```json
[
{
"id": 42069,
"username": "TESTUSERNAME",
"url": "https://myanimelist.net/profile/TESTUSERNAME",
"imageUrl": "https://cdn.myanimelist.net/images/userimages/42069.jpg?t=1652707800",
"lastOnline": "2022-01-01T06:26:42Z",
"gender": "",
"birthday": "0001-01-01T00:00:00Z",
"location": "TEST",
"joined": "2010-01-01T00:00:00Z"
}
]
```
### Watch
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/watch/{user?} | Watches von user oder allen | []AnimeUser JSON | {user?} = optional: MAL username | | |
| GET | /api/watchext/{user?} | Erweiterte Watches von user oder allen | []AnimeUserExtended JSON | {user?} = optional: MAL username | | |
| POST | /api/watch/{user} | Neuen watch schicken | []AnimeUser JSON | {user} = MAL username | X-HUSO-AUTH | []AnimeUser JSON |
| DELETE | /api/watch/{user} | Watch löschen | []AnimeUser JSON | {user} = MAL username | X-HUSO-AUTH | []AnimeUser JSON |
**Verwendung des JSON von GET und POST/DELETE unterscheiden sich. Bei POST/DELETE muss nur der zu verändernde Anime angegeben werden und sonst nichts.**
_[]AnimeUser_ (GET)
```json
[
{
"anime": 50265,
"users": [
{
"username": "TESTUSERNAME",
"malId": 42069,
"progress": 6,
"updated": "2022-05-15T20:44:35Z"
}
]
},
{
"anime": 40356,
"users": [
{
"username": "TESTUSERNAME",
"malId": 42069,
"progress": 3,
"updated": "2022-04-25T18:11:27Z"
}
]
}
]
```
_[]AnimeUserExtended_ (GET)
```json
[
{
"anime": 50265,
"users": [
{
"username": "TESTUSERNAME",
"malId": 42069,
"progress": 6,
"updated": "2022-05-15T20:44:35Z"
}
],
"data": { --SEE ANIME GET (Anime object)-- }
},
{
"anime": 40356,
"users": [
{
"username": "TESTUSERNAME",
"malId": 42069,
"progress": 3,
"updated": "2022-04-25T18:11:27Z"
}
],
"data": { --SEE ANIME GET (Anime object)-- }
}
]
```
_[]AnimeUser_ (POST/DELETE)
```json
[
{
"anime": 40356,
"users": []
}
]
```
### Chat
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/chat/{id} | Chat für Anime holen | Plaintext chat | {id} = MAL Anime id | | |
| POST | /api/chat/{id}/{user} | Chat für Anime senden | Plaintext chat mit neuer Nachricht | {id} = MAL Anime id; {user} = MAL username | X-HUSO-AUTH | Neue Nachricht in plaintext |
### Appointment [WIP]
| Method | Route | Description | Response | Parameter | Header | POST-Body |
| - | - | - | - | - | - | - |
| GET | /api/appointment | Appointments holen | []Appointment | | | |