xkcd.com API client in Go

go-xkcd

HTTP Client for the xkcd API.

wercker status Coverage Status GoDoc

https://xkcd.com/1481/

Details on the xkcd API can be found here.

Install

Outside a project using go modules, get the latest version by running:

go get github.com/nishanths/go-xkcd

Inside a project using go modules, use:

go get github.com/nishanths/go-xkcd@latest

Example

The following program prints details about xkcd.com/599:

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/nishanths/go-xkcd/v2"
)

func main() {
    client := xkcd.NewClient()

    comic, err := client.Get(context.Background(), 599)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s: %s\n", comic.Title, comic.ImageURL) // Apocalypse: http://imgs.xkcd.com/comics/apocalypse.png
}

Test

To run tests:

$ go test -race

Godoc

https://godoc.org/github.com/nishanths/go-xkcd

License

The MIT License. Copyright © Nishanth Shanmugham.

Similar Resources

Balabola-go-client - GO client for Yandex balabola service

Balabola GO Client GO client for Yandex balabola service Yandex warning The neur

Jan 29, 2022

Client-server-golang-sqs - Client Server with SQS and golang

Client Server with SQS and golang Multi-threaded client-server demo with Go What

Feb 14, 2022

Go Client Library for Amazon Product Advertising API

go-amazon-product-advertising-api Go Client Library for Amazon Product Advertising API How to Use go get -u github.com/ngs/go-amazon-product-advertisi

Sep 27, 2022

A Go client library for the Twitter 1.1 API

Anaconda Anaconda is a simple, transparent Go package for accessing version 1.1 of the Twitter API. Successful API queries return native Go structs th

Jan 1, 2023

Go client library for interacting with Coinpaprika's API

Coinpaprika API Go Client Usage This library provides convenient way to use coinpaprika.com API in Go. Coinpaprika delivers full market data to the wo

Dec 8, 2022

Golang client for ethereum json rpc api

Ethrpc Golang client for ethereum JSON RPC API. web3_clientVersion web3_sha3 net_version net_peerCount net_listening eth_protocolVersion eth_syncing e

Jan 7, 2023

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

Dec 26, 2022

📟 Tiny utility Go client for HackerNews API.

go-hacknews Tiny utility Go client for HackerNews API. Official Hackernews API Install go get github.com/PaulRosset/go-hacknews Usage Few examples a

Sep 27, 2022

A golang client for the Twitch v3 API - public APIs only (for now)

go-twitch Test CLIENT_ID="my client ID" go test -v -cover Usage Example File: package main import ( "log" "os" "github.com/knspriggs/go-twi

Sep 27, 2022
Comments
  • add: .gitignore, cli w/ manpage & makefile

    add: .gitignore, cli w/ manpage & makefile

    Just adds a command line interface to the library. Not sure if makefile should go in home or not. Should just need to add /cli to projdir variable in makefile if so.

    Man pages are only supported for linux and darwin systems right now

    Here's the main part of the readme:

    Usage

    xkcd [mode] [params]
    

    modes:

    • config
    • fetch
    • likes
    • random
    • help

    Examples

    xkcd help [mode]  # info on a given mode
    xkcd next  # fetch the comic whose index is one before the last one you saw
    xkcd prev  # fetch the comic whose index is one greater than the last comic you saw
    xkcd fetch -f  # fetch the latest comic even if you checked for it in the past 24 hours
    xkcd random  # fetch a random
    xkcd random -max 22  # fetch a random comic whose index is smaller than 22
    xkcd likes 12  # add comic number 12 to your likes
    

    Install

    git clone https://github.com/nishanths/go-xkcd
    cd go-xkcd/cli
    make
    
  • Tests shouldn't perform live HTTP requests

    Tests shouldn't perform live HTTP requests

    Performing live HTTP requests means we are dependent on external resources such as a working network connection, the xkcd.com API not being down, etc.

    But there is an advantage to doing live HTTP requests: it's quicker to be aware of breaking changes against the real API

Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Dec 5, 2022
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Jan 5, 2023
Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Jan 6, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

Nov 5, 2021
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022
Client for the cloud-iso-client

cloud-iso-client Client for the cloud-iso-client. Register an API token Before using this client library, you need to register an API token under your

Dec 6, 2021
Go-http-client: An enhanced http client for Golang
Go-http-client: An enhanced http client for Golang

go-http-client An enhanced http client for Golang Documentation on go.dev ?? This package provides you a http client package for your http requests. Y

Jan 7, 2023
Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Jan 18, 2022