REST Against Humanity¶
REST Against Humanity is a public API for Cards Against Humanity. You can use it to programatically obtain cards from any of Cards Against Humanity's 71 official packs.
You should probably read the rules of Cards Against Humanity before using this API.
Endpoints¶
Packs¶
https://restagainsthumanity.com/api/v2/packs
Names of Cards Against Humanity packs available through REST Against Humanity.
Parameters¶
None.
Example Response¶
Code Examples¶
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://restagainsthumanity.com/api/v2/packs"))
.GET()
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println(response.body());
}
Cards¶
Cards Against Humanity cards.
https://restagainsthumanity.com/api/v2/cards
Parameters¶
Name | Type | Description | Required? | Default |
---|---|---|---|---|
packs | string | A comma-separated, case-sensitive, list of packs to limit the response to. | No | All packs |
color | string | Limit the response to either black or white cards. Must be one of either "black" or "white". | No | N/A |
pick | integer | The pick that black cards in the response should be limited to. (A black card's pick is the number of blank spaces it has for white cards to fill.) Must be either 1 or 2. | No | N/A |
includePackNames | boolean | Whether to include the name of each card's originating pack in the response. | No | True |
Danger
It's important that you separate pack names with commas only — not commas and spaces.
For example, this is fine:
But this is not:
Unexpected whitespace will cause an HTTP 400 error.
Example Response¶
{
"black": [
{
"text": "_ + _ = Hipsters",
"pick": 2,
"pack": "CAH Base Set"
},
{
"text": "_ is a sure sign of mankind's decline.",
"pick": 1,
"pack": "CAH Base Set"
},
{
"text": "_ would only happen in my worst nightmares.",
"pick": 1,
"pack": "CAH Base Set"
}
],
"white": [
{
"text": "A balanced breakfast.",
"pack": "CAH Base Set"
},
{
"text": "A big hoopla about nothing.",
"pack": "CAH Base Set"
},
{
"text": "A cat with... hands.",
"pack": "CAH Base Set"
}
]
}
Code Examples¶
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://restagainsthumanity.com/api/v2/cards?packs=CAH Base Set,CAH: First Expansion"))
.GET()
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println(response.body());
}
let task = URLSession.shared.dataTask(with: URL(string: "https://restagainsthumanity.com/api/v2/cards?packs=CAH Base Set,CAH: First Expansion")!) { data, response, error in
if let data = data, let response = response as? HTTPURLResponse, response.statusCode == 200 {
print(String(data: data, encoding: .utf8)!)
}
}
task.resume()
require "net/http"
require "json"
uri = URI("https://restagainsthumanity.com/api/v2/cards?packs=CAH Base Set,CAH: First Expansion")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
if response.code == "200"
puts JSON.parse(response.body)
end