Installation Via pip:
pip install python-ninegag

Returns dict of 9gag sections, where keys are capitalized sections names, and values are their urls.

Example output:

{'Fresh': '',
'Cute Animals': '',
'Comic': '',
'Food': '',
'GIF': '',
'Cosplay': '',
'Geeky': '',
'Girl': '',
'Funny': '',
'Design': '',
'WTF': '',
'NSFW': '',
'Trending': '',
'Timely': '',
'Meme': '',
'Hot': ''
NOTE: NSFW section will return zero articles (empty iterable) since watching this section requires user login, which is not supported by this library.

These values are not hardcoded and will be generated on first request. Values are cached.

pyninegag.get_articles(url, max_pages=1)
Return iterable with all articles found on given url. max_pages - how many pages of results to parse. If None - all available. Default 1 - only first page.

Will return all articles on main 9gag page.

Example output:

    'id': 'a1MEzz6',
    'title': 'Jumping into the abyss',
    'data': {
        'type': 'gif',
        'url': ''
    'comments': '163',
    'votes': '10709',
    'url': ''
    'id': 'agVEP3g',
    'title': 'Made of crab',
    'data': {
        'type': 'image',
        'url': ''
    'comments': '257',
    'votes': '10053',
    'url': ''
Article type can be one of gif, image or longpost. Longpost is just a very tall image.

pyninegag.get_by_section(section_name, max_pages=1)
Return iterable with all articles found in given section. Section name must be one of the keys of pyninegag.get_sections(). If not found, ValueError will be raised.

There is also a logger pyninegag enabled that logs exceptions and warnings of parsing errors. All errors contain article id and url in message for easier debugging of problems.