> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/platform-services/pobieranie-tresci-i-tlumaczen.md).

# Retrieving content and translations

Interface `api.repository.v1` provides mechanisms that allow dynamic retrieval of the contents of artifacts of type **Content** (`TextContent`) defined in the Eximee Designer module. This functionality is crucial when a script must return an error message, generate dynamic text for the user interface, or send a message to an external system, taking into account centralized multilingual mechanisms (i18n).

{% hint style="info" %}
**Availability:** The functionality is available from platform version **3.332.0**.
{% endhint %}

## API methods

The process of retrieving a specific text consists of a chained call of three methods, which first locate the artifact itself, then select the appropriate language dictionary, and finally return the extracted plain text.

| Method / Call                                  | Return type | Operation description                                                                                                                                     |
| ---------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `api.repository.v1.textContent(name, version)` | `Object`    | Finds an artifact with the specified name in the repository `name` and version `version`. Most often, the character `"*"` (meaning the latest available). |
| `.language(langCode)`                          | `Object`    | Method called on the artifact object. It specifies a particular language code (e.g. `"pl"`, `"en"`).                                                      |
| `.text()`                                      | `String`    | Method called on the language object. Returns the target translated text value.                                                                           |

## Error handling and missing artifact

When retrieving content, special caution is required, because the engine rigorously verifies the correctness and existence of identifiers.

{% hint style="danger" %}
**System exceptions:**

1. The function `textContent()` **throws an exception**, if it does not find an artifact with the specified name and version in the repository.
2. The function `language()` **throws an exception**, if no translation for the requested language code is defined in the found artifact.
   {% endhint %}

## Usage examples

### 1. Retrieving the optimistic variant (Happy Path)

If we are absolutely sure that a given artifact exists in the database and has been published in the specified language, we can use the shortened form.

```javascript
function callService(context) {
    const artifactName = "stopka";
    const artifactVersion = "*"; // Asterisk means the latest available version
    const languageCode = "pl";
    
    // Chained retrieval of the object and extraction of the ready text
    const textContentArtifact = api.repository.v1.textContent(artifactName, artifactVersion);
    const footerText = textContentArtifact.language(languageCode).text();
    
    return [{'output': footerText}];
}
```

### 2. Safe retrieval using try-catch blocks (Recommended solution)

In a production environment – especially when search keys or language codes are passed dynamically (e.g. based on a parameter from `context` or the user's profile preferences) – errors should always be safely caught. This allows a fallback text to be returned instead of interrupting the entire script.

```javascript
function callService(context) {
    const artifactName = "stopka";
    const artifactVersion = "*";
    const languageCode = "pl";
    
    let textContentArtifact;
    
    // 1. Safe attempt to locate the artifact
    try { 
        textContentArtifact = api.repository.v1.textContent(artifactName, artifactVersion);
    } catch (error) {
        Logger.info("No Content artifact found with the name {} (version: {})", artifactName, artifactVersion);
        // Return the default value from the code (fallback)
        return [{'output': "Default system footer"}];
    }
    
    let footerText;
    
    // 2. Safe attempt to retrieve a specific translation
    try {
        footerText = textContentArtifact.language(languageCode).text(); 
    } catch (error) {
        Logger.info("No translation found in artifact {} for language: {}", artifactName, languageCode);
        return [{'output': "Default system footer (no specified language)"}];
    }
    
    // Return the correctly translated content
    return [{'output': footerText}];
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/platform-services/pobieranie-tresci-i-tlumaczen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
