basc_py4chan.Board – 4chan Boards

basc_py4chan.Board provides access to a 4chan board including checking if threads exist, retrieving appropriate basc_py4chan.Thread objects, and returning lists of all the threads that exist on the given board.


Here is a sample application that grabs and uses Board information:

from __future__ import print_function
import basc_py4chan

board = basc_py4chan.Board('tg')
thread_ids = board.get_all_thread_ids()
str_thread_ids = [str(id) for id in thread_ids]  # need to do this so str.join below works
print('There are', len(all_ids), 'active threads on /tg/:', ', '.join(str_thread_ids))

Basic Usage

class basc_py4chan.Board(board_name, https=False, session=None)[source]

Represents a 4chan board.


str – Name of this board, such as tg or k.


string – Name of the board, such as “tg” or “etc”.


string – Board title, such as “Animu and Mango”.


bool – Whether this board is worksafe.


int – How many pages this board has.


int – How many threads there are on each page.


Board.__init__(board_name, https=False, session=None)[source]

Creates a basc_py4chan.Board object.

  • board_name (string) – Name of the board, such as “tg” or “etc”.
  • https (bool) – Whether to use a secure connection to 4chan.
  • session – Existing requests.session object to use instead of our current one.

Check if a thread exists or has 404’d.

Parameters:thread_id (int) – Thread ID
Returns:Whether the given thread exists on this board.
Return type:bool
Board.get_thread(thread_id, update_if_cached=True, raise_404=False)[source]

Get a thread from 4chan via 4chan API.

  • thread_id (int) – Thread ID
  • update_if_cached (bool) – Whether the thread should be updated if it’s already in our cache
  • raise_404 (bool) – Raise an Exception if thread has 404’d

Thread object

Return type:



Returns all threads on a certain page.

Gets a list of Thread objects for every thread on the given page. If a thread is already in our cache, the cached version is returned and thread.want_update is set to True on the specific thread object.

Pages on 4chan are indexed from 1 onwards.

Parameters:page (int) – Page to request threads for. Defaults to the first page.
Returns:List of Thread objects representing the threads on the given page.
Return type:list of basc_py4chan.Thread

Return every thread on this board.

If not expanded, result is same as get_threads run across all board pages, with last 3-5 replies included.

Uses the catalog when not expanding, and uses the flat thread ID listing at /{board}/threads.json when expanding for more efficient resource usage.

If expanded, all data of all threads is returned with no omitted posts.

Parameters:expand (bool) – Whether to download every single post of every thread. If enabled, this option can be very slow and bandwidth-intensive.
Returns:List of Thread objects representing every thread on this board.
Return type:list of basc_py4chan.Thread

Return the ID of every thread on this board.

Returns:List of IDs of every thread on this board.
Return type:list of ints

Update all threads currently stored in our cache.


Remove everything currently stored in our cache.