A web API that scrapes a YouTube video's data and returns it as JSON
- Create a Python 3 virtual environment using Pipenv:
pipenv --three
- Activate the virtual environment and install the dependencies:
pipenv shell pipenv install --dev
With the virtual environment activated, run the following from the root directory of the project:
python -m scraper.api
The server should then be available at http://127.0.0.1:5000.
The API accepts GET requests at the /scrape
endpoint with the following parameters:
- ID of the YouTube video whose data is to be scraped.
http://127.0.0.1:5000/scrape?id=YdwOL08NfxQ
http://127.0.0.1:5000/scrape?id=n-DTjpde9-0
-
When data is successfully scraped for the given video ID.
200
{ "id": string, "title": string, "upload_date": string, "duration": string, "description": string, "thumbnail_url": string, "genre": string, "is_paid": boolean, "is_unlisted": boolean, "is_family_friendly": boolean, "uploader": { "channel_id": string, "name": string, "thumbnail_url": string, "is_verified": boolean }, "statistics": { "views": number, "likes": number, "dislikes": number } }
-
When no video corresponding to the given video ID is found.
404
{ "error": string }
This project is licensed under the terms of the MIT license.