A RESTful API made with FastAPI to obtain anime data from animepahe
- Python requests library + RegEx for web scraping
- FastAPI to create the RESTful API
- Docker to containerize the application
- Render to host the API
The API is hosted here https://weebapi.onrender.com/
To view the documentation for the API, simply go to https://weebapi.onrender.com/docs
The containerized images for every version are posted on Docker Hub here https://hub.docker.com/r/jshan9078/weeb-api/tags
Note: You can test the endpoints of the API from the documentation page linked above. Alternatively, simply construct a URL as follows.
Use this endpoint to obtain search results for a desired anime
https://weebapi.onrender.com/get_search_results/naruto
returns the following JSON data
Use this endpoint to obtain complete data for an anime series.
siteLink refers to the identifier https://animepahe.ru/anime/{identifier}
https://weebapi.onrender.com/get_full_data/90c9fc20-0c15-cee2-0d03-6f1fb998cec3
returns the following JSON data
Use this endpoint to obtain complete data for a particular episode.
siteLink refers to the identifier https://animepahe.ru/anime/{identifier}
https://weebapi.onrender.com/get_episode/90c9fc20-0c15-cee2-0d03-6f1fb998cec3/1
returns the following JSON data
Use this endpoint to obtain the download options for a particular episode.
episodeLink refers to the whole episode link
https://weebapi.onrender.com/get_download_options/https://animepahe.ru/play/f1af0e39-d51f-34e4-decb-761d18d39729/d9ad6a27917400b6582742c55b1e39be76d234524db0789302c87bc4f9e827dd
returns the following JSON data
Use this endpoint to obtain the download link
intermediaryPageLink refers to the https://pahe.win/
link
https://weebapi.onrender.com/get_download_link/https://pahe.win/NMZna
returns the following string data
As mentioned above, the API is inherently a web scraper that grabs data from animepahe. None of the content served through the API is owned or produced by me. I experimented with methods employing beautifulsoup4 and selenium, but found that simply using RegEx on the raw html from the frontend of the web pages worked more effeciently. These frontends are obtained by using requests sessions.
Animepahe employs a DDoS-Guard guard challenge. This is not of concern if one is hosting the API locally, but if it is being hosted on a service such as AWS or Google Cloud Run, the the python requests library fails to fetch the frontend of animepahe. To solve this, cookies and User-Agent HTTP headers can be used as shown in the various functions inside the weebAPI folder.
When one tries to download an episode off animepahe, there are options.
Clicking the 1080p option of this episode, will take me to this
pahe.win
page.
From here, clicking continue will take me to the following page on
kwix.cx
To get to the kwix.cx
page, decryption must be done on the pahe.win
site to get a token.
A download link can be obtained for a particular download option of a specific episode. To get this link, a POST request is made to the kwix.cx page. The location of the response is the download link.