Git Product home page Git Product logo

getxkcd's Introduction

getxkcd

Deploy with Vercel

get the latest comic

https://getxkcd.now.sh/latest
https://getxkcd.now.sh/0

example response

{
  "month": "1",
  "num": 2886,
  "link": "",
  "year": "2024",
  "news": "",
  "safe_title": "Fast Radio Bursts",
  "transcript": "",
  "alt": "Dr. Petroff has also shown that the Higgs boson signal was actually sparks from someone microwaving grapes, the EHT black hole photo was a frozen bagel someone left in too long, and the LIGO detection was just someone slamming the microwave door too hard.",
  "img": "https://imgs.xkcd.com/comics/fast_radio_bursts.png",
  "title": "Fast Radio Bursts",
  "day": "26"
}

get a comic by number

https://getxkcd.now.sh/1481

example response

{
  "month": "2",
  "num": 1481,
  "link": "",
  "year": "2015",
  "news": "",
  "safe_title": "API",
  "transcript": "((This is a faux-screenshot of a technical document))\n[[A figure sits at a computer upon a desk, apparently engrossed in the document which we now see before us.]]\nTITLE: API GUIDE\nRequest URL Format: domain\nuser\nitem\nServer will return an XML document which contains the requested data and documentation describing how the data is organized spatially.\nAPI KEYS: To obtain API access, contact the x.509-authenticated server and request an ECDH-RSA TLS key...\n\nCaption: If you do things right, it can take people a while to realize that your \"API documentation\" is just instructions for how to look at your website.\n\n{{Title text: ACCESS LIMITS: Clients may maintain connections to the server for no more than 86,400 seconds per day. If you need additional time, you may contact IERS to file a request for up to one additional second.}}",
  "alt": "ACCESS LIMITS: Clients may maintain connections to the server for no more than 86,400 seconds per day. If you need additional time, you may contact IERS to file a request for up to one additional second.",
  "img": "https://imgs.xkcd.com/comics/api.png",
  "title": "API",
  "day": "2"
}

notes

  • you can also get the latest comic by sending a request to https://getxkcd.now.sh/, but the request header should have Accept as application/json

    curl -H "Accept: application/json" "https://getxkcd.now.sh/""
  • the API is backwards compatible with the previous versions which used https://getxkcd.now.sh/api/comic?num=latest to get the latest comic and https://getxkcd.now.sh/api/comic?num=1172 to get a particular comic

  • if you get an HTML response from the API, you have to set your API client to handle redirects. alternatively, replace .now.sh domains with .vercel.app to avoid this pitfall in places like curl

  • vercel.json handles all the routing, so make sure you copy it verbatim if you want good things to happen

  • in an effort to learn and use a new programming language, i have used go which is unnecessarily complicating things but ✨ performance ✨

closing thoughts

made by khaleel when he was feeling lonely

getxkcd's People

Contributors

khalby786 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.