class Trefoil::Client

Overview

Used for making API requests. Instances are rate limited to one request per second as per the API documentation.

Defined in:

trefoil/board.cr
trefoil/client.cr

Constant Summary

BASE_URL = "https://a.4cdn.org/"

Base url for all API requests.

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def board(name : String) #

Creates a new board for making board specific requests


[View source]
def boards #

[View source]
def get(endpoint : String, if_modified_since : Time = Time::UNIX_EPOCH) : String #

Get the body of a request from a given endpoint. If we're rate limited the request is queued.


[View source]
def get?(endpoint : String, if_modified_since : Time = Time::UNIX_EPOCH) : String | Nil #

Like #get but if we're rate limited it returns nil instead of blocking.


[View source]
def rate_limited? : Bool #

Whether or not we are able to make another request


[View source]
def request(endpoint : String, if_modified_since : Time = Time::UNIX_EPOCH) #

[View source]
def retry_after : Time::Span #

The time span we have to wait before another request can be made


[View source]
def troll_flags #

[View source]