xkcd

App · Film, TV & Fandom · 8 actions

Pull xkcd comics into a workflow: the latest one, any comic by number, a random pick, or the comics from a stretch of the archive or a range of dates. Search all 3,000+ comics by title, hover text or transcript, check whether a new comic has gone up since last time, and download the picture to post or attach. Every comic comes back with its hover text: the joke that isn't in the image. No account or API key required.

Actions

ActionWhat it does
Download comic imageDownload a comic's picture as a file, so a later step can attach it to an email, post it to a chat or put it in storage.
Get a comicGet one comic by its number: the number in its address, so https://xkcd.com/614/ is comic 614.
Get a random comicGet a comic at random, picked by xkcd's own Random link, with its title, hover text and image.
Get new comics sinceGet the comics published since a comic number or a date: the check to run on a schedule.
Get the latest comicGet the comic currently on xkcd's front page, with its title, hover text, image and publication date.
List comicsList comics by number, newest first, a page at a time.
List comics by dateList the comics published between two dates, newest first: for a monthly digest, a year in review, or finding the comic that ran on a particular day.
Search comicsFind the comics whose title, hover text or transcript contains some text.

Download comic image

Download a comic's picture as a file, so a later step can attach it to an email, post it to a chat or put it in storage. Use this wherever a link will not do and the picture itself has to travel with the message. No API key required.

Inputs

Comic numbercomic_numbernumber
Optional. Which comic to download. Leave blank for the latest one.At least 1.

Outputs

byte_sizenumber
The file's size in bytes.
comicobject
The comic and everything xkcd publishes about it.
content_typetext
The image's media type, e.g. image/png.
document_reftext
The stored document's reference.
documentslist
The downloaded image as a document, ready to attach to a later step.
urltext
A URL that serves the stored file.
Example output
{
  "byte_size": 66677,
  "comic": {
    "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
    "comic_url": "https://xkcd.com/614/",
    "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
    "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
    "is_interactive": false,
    "link": null,
    "news": null,
    "number": 614,
    "published_date": "2009-07-24",
    "safe_title": "Woodpecker",
    "title": "Woodpecker",
    "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
  },
  "content_type": "image/png",
  "document_ref": "doc_xkcd_614",
  "documents": [
    {
      "content_type": "image/png",
      "document_ref": "doc_xkcd_614",
      "filename": "xkcd-614-woodpecker.png",
      "size_bytes": 66677,
      "url": "/actions/core/serve-document/doc_xkcd_614"
    }
  ],
  "url": "/actions/core/serve-document/doc_xkcd_614"
}

Get a comic

Get one comic by its number: the number in its address, so https://xkcd.com/614/ is comic 614. Returns the title, hover text, transcript, image and publication date. No API key required.

Inputs

Comic numbercomic_numbernumberRequired
The comic's number, as it appears in its address. There is no comic 404: xkcd skipped the number as a joke.At least 1.

Outputs

comicobject
The comic and everything xkcd publishes about it.
Example output
{
  "comic": {
    "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
    "comic_url": "https://xkcd.com/614/",
    "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
    "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
    "is_interactive": false,
    "link": null,
    "news": null,
    "number": 614,
    "published_date": "2009-07-24",
    "safe_title": "Woodpecker",
    "title": "Woodpecker",
    "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
  }
}

Get a random comic

Get a comic at random, picked by xkcd's own Random link, with its title, hover text and image. No API key required.

Inputs

None.

Outputs

comicobject
The comic and everything xkcd publishes about it.
Example output
{
  "comic": {
    "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
    "comic_url": "https://xkcd.com/614/",
    "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
    "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
    "is_interactive": false,
    "link": null,
    "news": null,
    "number": 614,
    "published_date": "2009-07-24",
    "safe_title": "Woodpecker",
    "title": "Woodpecker",
    "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
  }
}

Get new comics since

Get the comics published since a comic number or a date: the check to run on a schedule. Pass the latest comic number the last run reported, and this returns only what has appeared since. No API key required.

Inputs

Since comic numbersince_comic_numbernumber
Comics numbered above this one are new. Use the latest comic number from the previous run. Required unless a date is given instead.At least 0.
Since datesince_datedate
Comics published after this date are new. Use instead of, or together with, a comic number.
Number of comicslimitnumber
Optional. How many comics to return (the newest ones). Between 1 and 50; 10 by default. Each comic is fetched individually, so a smaller page is a faster step.From 1 to 50. Default: 10.

Outputs

comicslist
The new comics, newest first, up to the page size.
countnumber
How many comics are in this page.
has_moretrue/false
True when more comics matched than this page holds.
has_new_comicstrue/false
True when anything new was published. Branch on this to stay quiet on the days xkcd doesn't post.
latest_comic_numbernumber
The number of the newest comic. Store it and pass it back as Since comic number next run.
total_countnumber
How many comics matched in total, across every page.
Example output
{
  "comics": [
    {
      "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
      "comic_url": "https://xkcd.com/614/",
      "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
      "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
      "is_interactive": false,
      "link": null,
      "news": null,
      "number": 614,
      "published_date": "2009-07-24",
      "safe_title": "Woodpecker",
      "title": "Woodpecker",
      "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
    }
  ],
  "count": 1,
  "has_more": false,
  "has_new_comics": true,
  "latest_comic_number": 3287,
  "total_count": 1
}

Get the latest comic

Get the comic currently on xkcd's front page, with its title, hover text, image and publication date. No API key required.

Inputs

None.

Outputs

comicobject
The comic and everything xkcd publishes about it.
Example output
{
  "comic": {
    "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
    "comic_url": "https://xkcd.com/614/",
    "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
    "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
    "is_interactive": false,
    "link": null,
    "news": null,
    "number": 614,
    "published_date": "2009-07-24",
    "safe_title": "Woodpecker",
    "title": "Woodpecker",
    "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
  }
}

List comics

List comics by number, newest first, a page at a time. Leave the range blank for the most recent comics, or set it to walk a stretch of the archive. No API key required.

Inputs

From comic numberfrom_numbernumber
Optional. Only comics numbered this or higher. Leave blank to start at the very first comic.At least 1.
To comic numberto_numbernumber
Optional. Only comics numbered this or lower. Leave blank to run up to the newest comic.At least 1.
Oldest firstoldest_firsttrue/false
Optional. Return the oldest comics first instead of the newest. Off by default.Default: false.
Number of comicslimitnumber
Optional. How many comics to return. Between 1 and 50; 10 by default. Each comic is fetched individually, so a smaller page is a faster step.From 1 to 50. Default: 10.
Skipoffsetnumber
Optional. How many matching comics to skip before this page. Use the next offset from the previous result to page through. 0 by default.At least 0. Default: 0.

Outputs

comicslist
The comics in this page.
countnumber
How many comics are in this page.
has_moretrue/false
True when more comics matched than this page holds.
latest_comic_numbernumber
The number of the newest comic xkcd has published.
next_offsetnumber
The offset that fetches the next page. Null when this is the last one.
total_countnumber
How many comics matched in total, across every page.
Example output
{
  "comics": [
    {
      "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
      "comic_url": "https://xkcd.com/614/",
      "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
      "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
      "is_interactive": false,
      "link": null,
      "news": null,
      "number": 614,
      "published_date": "2009-07-24",
      "safe_title": "Woodpecker",
      "title": "Woodpecker",
      "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
    }
  ],
  "count": 1,
  "has_more": true,
  "latest_comic_number": 3287,
  "next_offset": 10,
  "total_count": 3286
}

List comics by date

List the comics published between two dates, newest first: for a monthly digest, a year in review, or finding the comic that ran on a particular day. No API key required.

Inputs

Published on or afterpublished_fromdate
Optional. Only comics published on or after this date.
Published on or beforepublished_todate
Optional. Only comics published on or before this date.
Oldest firstoldest_firsttrue/false
Optional. Return the oldest comics first instead of the newest. Off by default.Default: false.
Number of comicslimitnumber
Optional. How many comics to return. Between 1 and 50; 10 by default. Each comic is fetched individually, so a smaller page is a faster step.From 1 to 50. Default: 10.
Skipoffsetnumber
Optional. How many matching comics to skip before this page. Use the next offset from the previous result to page through. 0 by default.At least 0. Default: 0.

Outputs

comicslist
The comics in this page.
countnumber
How many comics are in this page.
has_moretrue/false
True when more comics matched than this page holds.
next_offsetnumber
The offset that fetches the next page. Null when this is the last one.
published_fromtext
The start of the window that was applied, YYYY-MM-DD. Null when no start was given.
published_totext
The end of the window that was applied, YYYY-MM-DD. Null when no end was given.
total_countnumber
How many comics matched in total, across every page.
Example output
{
  "comics": [
    {
      "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
      "comic_url": "https://xkcd.com/614/",
      "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
      "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
      "is_interactive": false,
      "link": null,
      "news": null,
      "number": 614,
      "published_date": "2009-07-24",
      "safe_title": "Woodpecker",
      "title": "Woodpecker",
      "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
    }
  ],
  "count": 1,
  "has_more": true,
  "next_offset": 10,
  "published_from": "2009-07-01",
  "published_to": "2009-07-31",
  "total_count": 14
}

Search comics

Find the comics whose title, hover text or transcript contains some text. Searching titles covers every comic ever published; searching the hover text or transcript opens comics one at a time, so narrow it with a number or date range. No API key required.

Inputs

Search textquerytextRequired
The text to look for. Matching ignores capitals and matches anywhere in the field, so "python" finds "Python Environment".
Search insearch_inlist
Optional. Which parts of a comic to search. Title only by default, which covers every comic in one request. Adding the hover text or transcript means opening comics one by one, bounded by Comics to scan.One or more of: title, alt_text (Hover text), transcript. Default: ["title"].
From comic numberfrom_numbernumber
Optional. Only comics numbered this or higher. Leave blank to start at the very first comic.At least 1.
To comic numberto_numbernumber
Optional. Only comics numbered this or lower. Leave blank to run up to the newest comic.At least 1.
Published on or afterpublished_fromdate
Optional. Only comics published on or after this date.
Published on or beforepublished_todate
Optional. Only comics published on or before this date.
Comics to scanmax_comics_scannednumber
Optional. The most comics to open when searching the hover text or transcript, newest first. Between 1 and 500; 100 by default. Ignored when only titles are searched, which needs no scanning at all.From 1 to 500. Default: 100.
Number of comicslimitnumber
Optional. How many comics to return. Between 1 and 50; 10 by default. Each comic is fetched individually, so a smaller page is a faster step.From 1 to 50. Default: 10.
Skipoffsetnumber
Optional. How many matching comics to skip before this page. Use the next offset from the previous result to page through. 0 by default.At least 0. Default: 0.

Outputs

comicslist
The matching comics in this page.
comics_scannednumber
How many comics were examined. For a title search this is every comic in the range.
countnumber
How many comics are in this page.
has_moretrue/false
True when more comics matched than this page holds.
next_offsetnumber
The offset that fetches the next page. Null when this is the last one.
querytext
The text that was searched for.
scan_limit_reachedtrue/false
True when the scan stopped at Comics to scan before reaching the end of the range, so older matches may exist. Raise the limit or narrow the range to be sure.
searched_inlist
The fields that were searched.
total_countnumber
How many comics matched in total, across every page.
Example output
{
  "comics": [
    {
      "alt_text": "If you don't have an extension cord I can get that too. Because we're friends! Right?",
      "comic_url": "https://xkcd.com/614/",
      "explanation_url": "https://www.explainxkcd.com/wiki/index.php/614",
      "image_url": "https://imgs.xkcd.com/comics/woodpecker.png",
      "is_interactive": false,
      "link": null,
      "news": null,
      "number": 614,
      "published_date": "2009-07-24",
      "safe_title": "Woodpecker",
      "title": "Woodpecker",
      "transcript": "[[A man with a beret and a woman are standing on a boardwalk, leaning on a handrail.]]\nMan: A woodpecker!"
    }
  ],
  "comics_scanned": 3286,
  "count": 1,
  "has_more": false,
  "next_offset": null,
  "query": "woodpecker",
  "scan_limit_reached": false,
  "searched_in": [
    "title"
  ],
  "total_count": 3
}

On this page