Description
A robust API for koutube that can be used in applications such as Discord bots (e.g. for faster or prettier embeds) would be a nice addition. It should basically return all the data from an embed but in a machine-readable JSON format instead of the spec-horror HTML. I currently don't have time to work on this. This should be as easy, however, as early returning embedData
or its equivalent from each handler, plus all the logic to handle checking for whether or not it's a request to the API rather than the service.
- API must work with all content types (playlists, mixes, images, videos and channels)
- API must return the content type that has been recognized
- API should probably cache but not display in the listing.
- API should operate on
/api
but otherwise handle normally, so GETting/api/dQw4w9WgXcQ
should return the data to anyone who asks (not just bots). - The API should support all the same URL params we have
- The API must be documented in a separate markdown document outlining all available parameters and quirks as well as response schemas.
- API must return the data available in the embed, in no particular order. Depending on availability:
- Site name (the constant appName)
- Theme color
- Player stream URL - just the working one that gets ultimately chosen in the embed
- Video width and height
- Image
- Description
- Original (redirect) URL to real youtube
- Author name
- Upload date text
- Like count
- Dislike count
- Subscriber count
- Followers count
- View count
- Video/song count
- Image data (if present for the embed image generator)
- Error text, if present
The presence of each data point depends on which content the embed is for and if it actually exists.
I'd prefer if it was done in a clean way without major refactoring of the current structure. There's a lot of logic to be very mindful of.