A web API that scrapes a YouTube video's data and returns it as JSON
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scraper Add files Jun 17, 2018
.gitignore Initial commit Jun 17, 2018
LICENSE Initial commit Jun 17, 2018
Pipfile Add files Jun 17, 2018
Pipfile.lock Add files Jun 17, 2018
README.md Fix syntax highlighting in README Sep 2, 2018

README.md

YouTube scraper API

A web API that scrapes a YouTube video's data and returns it as JSON

Setup

  1. Create a Python 3 virtual environment using Pipenv:
    pipenv --three
  2. Activate the virtual environment and install the dependencies:
    pipenv shell
    pipenv install --dev

Start the server

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.

API

Requests

The API accepts GET requests at the /scrape endpoint with the following parameters:

  • id

    ID of the YouTube video whose data is to be scraped.

Example URLs

  • http://127.0.0.1:5000/scrape?id=YdwOL08NfxQ
  • http://127.0.0.1:5000/scrape?id=n-DTjpde9-0

Responses

  • Successful response

    When data is successfully scraped for the given video ID.

    Status code

    200

    Format

    {
        "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
        }
    }
  • Error response

    When no video corresponding to the given video ID is found.

    Status code

    404

    Format

    {
        "error": string
    }

License

This project is licensed under the terms of the MIT license.