Categorygithub.com/peterhellberg/swapi
modulepackage
0.0.0-20230222134402-c0bd79f5129c
Repository: https://github.com/peterhellberg/swapi.git
Documentation: pkg.go.dev

# README

A SWAPI client written in Go

Build status Go Report Card GoDoc License MIT

Installation

go get -u github.com/peterhellberg/swapi

Examples

atst.go

package main

import (
	"context"
	"fmt"

	"github.com/peterhellberg/swapi"
)

func main() {
	c := swapi.DefaultClient

	if atst, err := c.Vehicle(context.Background(), 19); err == nil {
		fmt.Println("name: ", atst.Name)
		fmt.Println("model:", atst.Model)
	}
}

Command line tool

Installation

go install github.com/peterhellberg/swapi/cmd/swapi@latest

Usage

Commands:
	film     [id]
	person   [id]
	planet   [id]
	species  [id]
	starship [id]
	vehicle  [id]
	films
	people
	planets
	films
	species
	vehicles
	starships
$ swapi planet 1
{
  "name": "Tatooine",
  "rotation_period": "23",
  "orbital_period": "304",
  "diameter": "10465",
  "climate": "arid",
  "gravity": "1 standard",
  "terrain": "desert",
  "surface_water": "1",
  "population": "200000",
  "residents": [
    "http://swapi.dev/api/people/1/",
    "http://swapi.dev/api/people/2/",
    "http://swapi.dev/api/people/4/",
    "http://swapi.dev/api/people/6/",
    "http://swapi.dev/api/people/7/",
    "http://swapi.dev/api/people/8/",
    "http://swapi.dev/api/people/9/",
    "http://swapi.dev/api/people/11/",
    "http://swapi.dev/api/people/43/",
    "http://swapi.dev/api/people/62/"
  ],
  "films": [
    "http://swapi.dev/api/films/1/",
    "http://swapi.dev/api/films/3/",
    "http://swapi.dev/api/films/4/",
    "http://swapi.dev/api/films/5/",
    "http://swapi.dev/api/films/6/"
  ],
  "created": "2014-12-09T13:50:49.641000Z",
  "edited": "2014-12-21T20:48:04.175778Z",
  "url": "http://swapi.dev/api/planets/1/"
}

License (MIT)

Copyright (c) 2014-2023 Peter Hellberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Packages

No description provided by the author

# Functions

BaseURL for the client parsed from provided rawurl.
FromEnv client configuration.
HTTPClient to use by the client.
NewClient returns a new SWAPI client.
UserAgent to use by the client.

# Variables

DefaultClient is the default SWAPI client.

# Structs

A Client communicates with SWAPI.
A Film is an single film.
No description provided by the author
A Person is an individual person or character within the Star Wars universe.
A Planet is a large mass, planet or planetoid in the Star Wars Universe, at the time of 0 ABY.
A Species is a type of person or character within the Star Wars Universe.
A Starship is a single transport craft that has hyperdrive capability.
A Vehicle is a single transport craft that does not have hyperdrive capability.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author