Module: Fourchan::Kit::API
- Defined in:
- lib/fourchan/kit/api.rb
Overview
This module contains methods for the 4chan API.
They all parse the JSON 4chan delivers and returns an Array object.
Class Method Summary (collapse)
-
+ (Array) get_boards
Returns information for all boards across 4chan.
-
+ (Array) get_catalog(board)
Returns information for all threads on specified board.
-
+ (Array) get_page(board, page)
Returns the threads at a page number on specified board.
-
+ (Array) get_thread(board, thread)
Returns all posts for the specified thread.
-
+ (Array) get_threads(board)
Returns only id and time for threads on specified board.
Class Method Details
+ (Array) get_boards
Returns information for all boards across 4chan.
16 17 18 |
# File 'lib/fourchan/kit/api.rb', line 16 def self.get_boards JSON.parse(open("http://a.4cdn.org/boards.json").read)['boards'] end |
+ (Array) get_catalog(board)
Returns information for all threads on specified board.
25 26 27 |
# File 'lib/fourchan/kit/api.rb', line 25 def self.get_catalog(board) JSON.parse(open("http://a.4cdn.org/#{board}/catalog.json").read) end |
+ (Array) get_page(board, page)
Returns the threads at a page number on specified board.
4chan stopped using zero-index pages in April. Instead of first page is at 0, it is now at 1. 0 returns nothing.
57 58 59 |
# File 'lib/fourchan/kit/api.rb', line 57 def self.get_page(board, page) JSON.parse(open("http://a.4cdn.org/#{board}/#{page}.json").read)['threads'] end |
+ (Array) get_thread(board, thread)
Returns all posts for the specified thread.
44 45 46 |
# File 'lib/fourchan/kit/api.rb', line 44 def self.get_thread(board, thread) JSON.parse(open("http://a.4cdn.org/#{board}/thread/#{thread}.json").read)['posts'] end |
+ (Array) get_threads(board)
Returns only id and time for threads on specified board.
34 35 36 |
# File 'lib/fourchan/kit/api.rb', line 34 def self.get_threads(board) JSON.parse(open("http://a.4cdn.org/#{board}/threads.json").read) end |