PhotoCheck API

PhotoCheck API in Go

To check a photo for AI generation and faces in Go, POST it to https://photocheckapi.com/api/v1/analyze with your key as a Bearer token. The response is JSON with ai.score, faces.count and the file's metadata. The example below is complete and runs as it is.

1. Set your key

shell
export PHOTOCHECK_API_KEY="pc_live_…"

No key yet? Leave the header out: you get 5 keyless calls a day to try it. Credit packs start at $4.95.

2. Check a photo

Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	file, _ := os.Open("photo.jpg")
	defer file.Close()

	var body bytes.Buffer
	form := multipart.NewWriter(&body)
	part, _ := form.CreateFormFile("image", "photo.jpg")
	io.Copy(part, file)
	form.Close()

	req, _ := http.NewRequest("POST", "https://photocheckapi.com/api/v1/analyze", &body)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("PHOTOCHECK_API_KEY"))
	req.Header.Set("Content-Type", form.FormDataContentType())

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var result struct {
		Summary struct{ Text string } `json:"summary"`
		AI      struct{ Score float64 } `json:"ai"`
		Error   *struct{ Type, Message string } `json:"error"`
	}
	json.NewDecoder(res.Body).Decode(&result)
	if result.Error != nil {
		panic(result.Error.Type + ": " + result.Error.Message)
	}
	fmt.Println(result.Summary.Text, result.AI.Score)
}

Notes

  • Standard library only.
  • Error handling is trimmed for length; check every err in real code.
  • Swap /analyze for /faces, /ai-detect or /metadata to run one check. Each costs the same one credit.
  • Branch on error.type rather than the HTTP status alone; the full list is in the error reference.

Other languages

cURL, JavaScript (Node.js), Python, PHP, Ruby, Java, C# (.NET), Rust.