> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reverieinc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> Translation is the REST API developed for localizing the contents from English to Indic languages. Using the Translation API, you can either localize a single sentence or multiple sentences in a fraction of time.

In this guide, you’ll learn how to automatically transcribe live streaming audio in real time using Reverie's SDKs, which are supported for use with the Reverie API.

<Note>
  Before you start, you'll need to follow the steps in the [Get your API
  Credentials](/authentication) to obtain your API KEY & APP ID.
</Note>

### Make your first Call

Make your first API Call using the cURL request. Add your own API Credentials where it says `<YOUR-APP-ID>` & `<YOUR-API-KEY>`
and then run the following example in a terminal or your favorite API client.

```bash theme={null}
curl --location --request POST 'https://revapi.reverieinc.com/' \
--header 'Content-Type: application/json' \
--header 'REV-API-KEY: <YOUR API KEY>' \
--header 'REV-APP-ID: <YOUR APP-ID>' \
--header 'src_lang: en' \
--header 'tgt_lang: hi' \
--header 'domain: generic' \
--header 'REV-APPNAME: localization' \
--header 'REV-APPVERSION: 3.0' \
--data '{
    "data": [
        "Reverie Language Technologies was established in 2009.",
        "The company head office is located in Bengaluru."
    ]
}'
```

By default, The API will return the strings in the target language.

### SDKs

Reverie has several SDKs that can make it easier to use the API.
Follow these steps to use the SDK of your choice to make a Reverie Translation request.

### Install Dependencies

<CodeGroup>
  ```bash JavaScript theme={null}
  npm i @reverieit/reverie-client
  ```

  ```bash Python theme={null}
  pip install reverie-sdk
  ```
</CodeGroup>

### Translate Text to your preferred language

The following code shows how to convert the text to your preferred language.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const ReverieClient = require("@reverieit/reverie-client");

  const reverieClient = new ReverieClient({
    apiKey: "YOUR-API-KEY",
    appId: "YOUR-APP-ID",
  });

  async function translateText() {
    const translation = await reverieClient.translate({
      text: "Hey there, how are you doing?",
      src_lang: "en",
      tgt_lang: "or",
    });
    console.log(translation);
  }

  translateText();
  ```

  ```python Python theme={null}
  from reverie_sdk import ReverieClient

  client = ReverieClient(
      api_key="MY_API_KEY",
      app_id="MY_APP_ID",
  )


  resp = client.nmt.Translation(
      data=[
          "Reverie Language Technologies was established in 2009.",
          "The company head office is located in Bangalore.",
      ],
      domain=1,
      src_lang="en",
      tgt_lang=["hi"],
      nmtMask=True,
      nmtMaskTerms=["Reverie Language Technologies"],
      nmtParam=True,
      dbLookupParam=True,
      segmentationParam=False,
  )

  print(resp)
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"log"
  	"net/http"
  )

  const (
  	apiURL = "https://revapi.reverieinc.com/"
  	apiKey     = "<YOUR API KEY>"
  	appID      = "<YOUR APP ID>"
  )

  type RequestBody struct {
  	Data                 []string `json:"data"`
  	IsBulk               bool     `json:"isBulk"`
  	IgnoreTaggedEntities bool     `json:"ignoreTaggedEntities"`
  }

  type APIResponse struct {
  	ResponseList []struct {
  		APIStatus int    `json:"apiStatus"`
  		InString  string `json:"inString"`
  		OutString string `json:"outString"` // Change []string to string
  	} `json:"responseList"`
  	TokenConsumed int `json:"tokenConsumed"`
  }


  func main() {
  	text := "Reverie Language Technologies ltd is a great place to work."

  	// Constructing JSON Request Body
  	requestBody := map[string]interface{}{
  		"data":                 []string{text},
  		"isBulk":               false,
  		"ignoreTaggedEntities": false,
  	}

  	jsonData, err := json.Marshal(requestBody)
  	if err != nil {
  		log.Fatalf("Error marshaling JSON: %v", err)
  	}

  	// Creating HTTP Request
  	req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(jsonData))
  	if err != nil {
  		log.Fatalf("Error creating request: %v", err)
  	}

  	// Setting Request Headers
  	req.Header.Set("Content-Type", "application/json")
  	req.Header.Set("REV-API-KEY", apiKey)
  	req.Header.Set("REV-APP-ID", appID)
  	req.Header.Set("src_lang", "en")
  	req.Header.Set("tgt_lang", "hi")
  	req.Header.Set("domain", "1")
  	req.Header.Set("cnt_lang", "en")
  	req.Header.Set("REV-APPNAME", "Translation")

  	// Making HTTP Request
  	client := &http.Client{}
  	resp, err := client.Do(req)
  	if err != nil {
  		log.Fatalf("Error making request: %v", err)
  	}
  	defer resp.Body.Close()

  	// Handle non-200 response codes
  	if resp.StatusCode != http.StatusOK {
  		log.Fatalf("Unexpected API response status: %d", resp.StatusCode)
  	}

  	// Read Response Body
  	body, err := io.ReadAll(resp.Body)
  	if err != nil {
  		log.Fatalf("Error reading response body: %v", err)
  	}

  	// Unmarshalling JSON Response
  	var apiResponse APIResponse
  	err = json.Unmarshal(body, &apiResponse)
  	if err != nil {
  		log.Fatalf("Error unmarshaling response: %v", err)
  	}

  	// Check if response contains valid translation
  	if len(apiResponse.ResponseList) > 0 {
  		response := apiResponse.ResponseList[0]
  		if len(response.OutString) > 0 {
  			fmt.Println("Translated Text:", response.OutString)
  		} else {
  			fmt.Println("No translated text received.")
  		}

  		// Handling API Status
  		if response.APIStatus != 3 { // Example: 3 might indicate partial success
  			fmt.Printf("Warning: API returned status %d\n", response.APIStatus)
  		}
  	} else {
  		fmt.Println("No response from API")
  	}
  }
  ```
</CodeGroup>

### Results

In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell.

<CodeGroup>
  ```bash JavaScript theme={null}
  # Run your application using the file you created in the previous step
  # Example:
  npm start
  ```

  ```python Python theme={null}
  # Run your application using the file you created in the previous step
  # Example:
  python main.py
  ```

  ```go GoLang theme={null}
  // Run your application using the file you created in the previous step
  // Example:
  go run main.go
  ```
</CodeGroup>

### Analyzing the Response

The API returns a `responseList`, which is an array containing the localized content. Each item includes the `inString`, representing the original input text in the source language, and the corresponding `outString`, which contains the translated text in the requested target language.
