Skip to content

imager200/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

client

Golang client for the imager200 API

the client provides bindings for interacting with the imager200 API. It is auto-generated from the official open api specs: https://www.imager200.io/imager200.json

To use the API, a (free) registration is needed in order to obtain the API key.

Installation

go get -u github.com/imager200/go-sdk

Example usage:

package main

import (
	"bytes"
	"context"
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/imager200/go-sdk/client"
	"github.com/imager200/go-sdk/generated"
)

func main() {
	cl, err := client.NewImager200Client("Set you API key here")
	if err != nil {
		log.Fatal(err.Error())
	}

	ctx := context.Background()
	fb, err := os.ReadFile("jpeg_image.jpg")
	if err != nil {
		log.Fatal(err.Error())
	}

	// Example 1: /grayscale/sync using POST
	resp, err := cl.GrayscaleSyncPostWithBodyWithResponse(ctx, client.ApplicationOctetStreamContentType, bytes.NewBuffer(fb))
	if err != nil {
		log.Fatal(err.Error())
	}

	if resp.StatusCode() != http.StatusOK {
		log.Fatalf("received non ok status: %d, response: %s", resp.StatusCode(), string(resp.Body))
	}

	if err := os.WriteFile("grayscaled.jpg", resp.Body, 0644); err != nil {
		log.Fatal(err.Error())
	}
}

More examples can be found in the examples directory.

Request editors:

For each special header described in the API docs, a RequestEditorFn is available: