[ `Question` ] : Is it possible to get the total number of anime available in the database?
Closed this issue · 2 comments
Hi there,
Its me again and i have a small question.
Is it possible to get the total number of entries available in the database somehow?
For example
Lets suppose that i want to seed my database using jikan.moe. Now i can do a while loop to get data from api.jikan.moe/anime
. But this will continue forever ( unless i set a range )
Now the question here is that is it possible to get the total number of animes ( so that i can set the upper range )
Thanks :D
You can use the information in pagination
e.g https://api.jikan.moe/v4/anime
"pagination": {
"last_visible_page": 1008,
"has_next_page": true,
"current_page": 1,
"items": {
"count": 25,
"total": 25184, // this is the total number of anime entires in the DB
"per_page": 25
}
},
You could also just use has_next_page
to keep track of whether you've hit the last page or not or if you need to know what the last page is you can check last_visible_page
.
Feel free to join our discord server for any support questions: http://discord.jikan.moe/
I got my answer
Thanks for responding quickly.
Oopps sorry i overlooked discord :)
Next time i will try contacting there.
Thanks :D
Edit 1 :
Its not what i was looking for actually. But i will do a follow up in discord :D
Edit 2 :
I have an implementation using python.
import requests
ANIME_NUMBER = 1
STARTING_NUMBER = 1
FINISH_NUMBER = 25_184
while STARTING_NUMBER <= FINISH_NUMBER:
res = requests.get(f"https://api.jikan.moe/v4/anime/{ANIME_NUMBER}")
data = res.json()
if res.status_code == 200:
STARTING_NUMBER += 1
# Do whatever you want with data
ANIME_NUMBER += 1