Skip to content

Commodore68/comic-strip-api

Repository files navigation

comic-strip-api

An API for developers of frontends to easily retrieve daily comic strip image links and metadata by date

To see currently supported comic strips, see Supported Comics

API, through a simple UI, is currently served at https://get-comic-strips.herokuapp.com

The API accepts GET requests at the https://get-comic-strips.herokuapp.com/api endpoint

The API can also be run locally by downloading this project doing npm start (requires Node.js and npm)

API Parameters

  • comicName: the name of the comic to get information on (required)
  • date: a date string currently only accepts yyyy-mm-dd formatted dates
    • this is not a required value
  • An alternative to passing a single date string (this is also not required)
    • year: a year in the format yyyy
    • month: a month in the format mm
    • day: a day in the format dd

Note: if no date is passed when interacting with the API, it will use today's date

Error Handling

If no config for the comic passed, it will respond with a 404 error

If a malformed date is passed, it will respond with a 400 error

If for any reason the request to the generated url for the comic strip is refused, it will respond with a 404 error

If for any reason the html pulled from the webpage fails to be parsed, it will respond with a 500 error

Config Format

configuration files will have to be added for any comic that this is to be used for

configuration files should be in the format:

{
    "comic": SomeComicName,
    "baseUrl": "https://www.someComicName.com/strip/",
    "dateFormat": "the date format for the url",
    "htmlTags": [
        {
            "name": "image",
            "value": "image html class or id"
        },
        {
            "name": "date",
            "value": "date html class or id"
        },
        {
            "name": "title",
            "value": "title html class or id"
        },
        {
            "name": "tags",
            "value": "tags html class or id"
        },
        {
            "name": "transcript",
            "value": "transcript html class or id"
        }
    ]
}

Notes

The tags can be omitted as is appropriate.

The API will also return the alt text for any image tag

If any page does not contain the tags specified, the API will not return anything for that tag

Config files should be placed in the comic-config folder, and the file should be named the same as the comic

Future Tasks

  • accept more date formats
  • add more comic strips
  • add a way for a user to generate and use tokens for authenticating users
  • make it work with POST requests
  • return the tags and other long properties in a cleaner formatting
  • improve the unit testing coverage
  • look into switching test framework to tap