A Go client and command line application for the Radio Garden API.
The client is autogenerated by oapi-codegen from radio-garden-openapi, an unofficial Radio Garden OpenAPI specification.
This package includes two client variants:
Client
returns raw HTTP responses.ClientWithResponses
is a wrapper aroundClient
with response type handling.
import (
"context"
"fmt"
radiogarden "github.com/jonasrmichel/radio-garden-go"
)
func main() {
// construct a client
client, err := radiogarden.NewClientWithResponses("https://radio.garden/api")
if err != nil {
panic(err)
}
// get a radio station's details
res, err := client.GetAraContentChannelChannelIdWithResponse(
context.Background(),
"9bd5454",
)
if err != nil {
panic(err)
}
// print the station's details
fmt.Printf("%+v", res.JSON200.Data)
}
The client implementation is generated by oapi-codegen. Any Radio Garden API changes will require that the client be updated.
Run the following commands to update the client:
# install oapi-codegen (see below)
$ go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
# generate the client
$ go generate ./...
# install any missing dependencies
$ go mod tidy
Currently, oapi-codegen does not support the OpenAPI oneOf
or anyOf
keywords.
That caveat is addressed by this pull request.
To update the client with support for oneOf
and anyOf
schema types, download and install that PR's fork manually:
# clone ispringtech's oapi-codegen fork
$ git clone -b union [email protected]:ispringtech/oapi-codegen.git
# go there
$ cd oapi-codegen
# install oapi-codegen
$ go install ./cmd/oapi-codegen
The client implementation in this project does include type level support for oneOf
and anyOf
schema types generated by the above fork.
Run the following commands to install and run the radio-garden
command line application:
# install the radio-garden cli app
$ go install github.com/jonasrmichel/radio-garden-go/radio-garden
# run the app
$ radio-garden -h
An application for using the Radio Garden API
Usage:
radio-garden [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
geo Get your geolocation
help Help about any command
place Get a place's details
places Get places with registered radio stations
search Search for countries, places, and radio stations
station Get a radio station's details
stations Get a place's registered radio stations
Flags:
-f, --format format the output
-h, --help help for radio-garden
-s, --server string the Radio Garden server (default "https://radio.garden/api")
Use "radio-garden [command] --help" for more information about a command.
The client and CLI tool in this project are released under the Apache 2.0 License. Radio Garden and its API are copyrighted by Radio Garden BV.