
# Go {/* #go */}

Empieza por la [guía REST](/docs/es/api/rest) para obtener un token API de la plataforma. Este ejemplo utiliza la biblioteca estándar de Go; no requiere generar clientes ni paquetes adicionales.

Guarda como `main.go`:

```go
package main

import (
    "encoding/json"
    "fmt"
    "log"
    "net/http"
    "net/url"
    "os"
    "time"
)

type catalog struct {
    ID string `json:"catalogId"`
}
type page struct {
    Catalogs []catalog `json:"catalogs"`
    NextPageToken string `json:"nextPageToken"`
}
type detail struct {
    ID string `json:"catalogId"`
    Description string `json:"description"`
}

func main() {
    token := os.Getenv("CR_RECONSTRUCT_API_TOKEN")
    if token == "" { log.Fatal("set CR_RECONSTRUCT_API_TOKEN") }
    base := "https://reconstruct.dev/api/v1/platform"
    client := &http.Client{Timeout: 10 * time.Second}

    get := func(path string, result any) error {
        req, err := http.NewRequest(http.MethodGet, base+path, nil)
        if err != nil { return err }
        req.Header.Set("Authorization", "Bearer "+token)
        resp, err := client.Do(req)
        if err != nil { return err }
        defer resp.Body.Close()
        if resp.StatusCode != http.StatusOK {
            return fmt.Errorf("API returned %s", resp.Status)
        }
        return json.NewDecoder(resp.Body).Decode(result)
    }

    var first page
    if err := get("/catalogs?pageSize=10", &first); err != nil { log.Fatal(err) }
    for _, item := range first.Catalogs {
        var info detail
        if err := get("/catalogs/"+url.PathEscape(item.ID), &info); err != nil {
            log.Fatal(err)
        }
        fmt.Println(info.ID, info.Description)
    }
    if first.NextPageToken != "" { fmt.Println("Next page token:", first.NextPageToken) }
}
```

Ejecuta `go run main.go`. Envía `nextPageToken` como parámetro de consulta `pageToken` codificado para URL para continuar por el catálogo.
