# Fetch History

> The `step` is optional. If skipped, the history of the latest stage will be returned.

{% openapi src="<https://4246159311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJc2Olnfmy17B0BpCm82C%2Fuploads%2Fgit-blob-5050e1639ebc3dccc8449cfb5488b2a8e5510689%2Fopenapi3_0%20(5).json?alt=media>" path="/api/task/rodin\_history" method="post" expanded="true" %}
[openapi3\_0 (5).json](https://4246159311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJc2Olnfmy17B0BpCm82C%2Fuploads%2Fgit-blob-5050e1639ebc3dccc8449cfb5488b2a8e5510689%2Fopenapi3_0%20\(5\).json?alt=media)
{% endopenapi %}

### Examples

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"time"
)

const BaseURI = "https://hyperhuman.deemos.com/api"

var client = &http.Client{Timeout: 10 * time.Second}

type HistoryInfoDto struct {
	Model          *string `json:"model,omitempty"`
	TextureDiffuse *string `json:"texture_diffuse,omitempty"`
	TexturePbr     *string `json:"texture_pbr,omitempty"`
	TextureShaded  *string `json:"texture_shaded,omitempty"`
	PreviewImage   *string `json:"preview_image,omitempty"`
	Settings       *string `json:"settings,omitempty"`
	GenerateTime   *string `json:"generate_time,omitempty"`
}

type CommonError struct {
	Error *string `json:"error,omitempty"`
}

type RodinModelHistoryResponse struct {
	CommonError
	HistoryInfo map[string]HistoryInfoDto `json:"history_info,omitempty"`
}

type RodinTextureHistoryResponse struct {
	CommonError
	HistoryInfo map[string]map[string]HistoryInfoDto `json:"history_info,omitempty"`
}

func rodinHistory(token string, taskUUID string, step string) (*http.Response, error) {
	// Create the request body
	data := map[string]string{"uuid": taskUUID, "step": step}
	jsonData, err := json.Marshal(data)
	if err != nil {
		return nil, err
	}

	// Create the request
	req, err := http.NewRequest("POST", fmt.Sprintf("%s/task/rodin_history", BaseURI), bytes.NewBuffer(jsonData))
	if err != nil {
		return nil, err
	}

	// Set headers
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	// Send the request
	return client.Do(req)
}

func RodinModelHistory(token string, taskUUID string) (*RodinModelHistoryResponse, error) {
	resp, err := rodinHistory(token, taskUUID, "ModelGenerate")
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// Decode the response JSON
	var raw json.RawMessage
	var result RodinModelHistoryResponse
	err = json.NewDecoder(resp.Body).Decode(&raw)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result.HistoryInfo)
	if err != nil {
		return nil, err
	}

	if result.Error != nil {
		return nil, fmt.Errorf("error: %s", *result.Error)
	}

	return &result, nil
}

func RodinTextureHistory(token string, taskUUID string) (*RodinTextureHistoryResponse, error) {
	resp, err := rodinHistory(token, taskUUID, "TextureGenerate")
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// Decode the response JSON
	var raw json.RawMessage
	var result RodinTextureHistoryResponse
	err = json.NewDecoder(resp.Body).Decode(&raw)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result.HistoryInfo)
	if err != nil {
		return nil, err
	}

	if result.Error != nil {
		return nil, fmt.Errorf("error: %s", *result.Error)
	}

	return &result, nil
}

func main() {
	token := "eyJhbGciOiJIUzI1NiJ9.your.token"

	modelResult, err := RodinModelHistory(token, "01234567-your-uuid-here-0123456789ab")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(*modelResult.HistoryInfo["v1"].PreviewImage)

	textureResult, err := RodinTextureHistory(token, "01234567-your-uuid-here-0123456789ab")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(*textureResult.HistoryInfo["0000.png"]["v1"].PreviewImage)
}

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://on-premises.docs.hyper3d.ai/task/fetch-history.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
