# Profit and Loss

This API retrieves the profit and loss statement of a company based on the provided company code (`cocode`) and report type (`reportType`), such as `S` (Single) or `C` (Consolidated). The response includes key financial metrics for several fiscal years, such as revenue, expenses, profit, tax before and after profit and Operating Profit after Depreciation.

**Note:** `cocode` can be obtained from the Search Stock or Company Basic Detail API.

**Endpoint**

```
https://connects.torusdigital.com/api/v1/profitandloss/{cocode}/{reportType}
```

**Request Parameter**

<table><thead><tr><th width="181">Name</th><th width="125">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>cocode</td><td>Y</td><td>The unique company code identifier.</td></tr><tr><td>reportType</td><td>Y</td><td>The type of report to retrieve. Report type (S - Single or C - Consolidated)</td></tr></tbody></table>

**Request**

{% tabs %}
{% tab title="curl" %}
{% code title="cURL" overflow="wrap" lineNumbers="true" %}

```javascript
curl -X 'GET' \
  'https://connects.torusdigital.com/api/v1/profitandloss/{cocode}/{reportType}' \
  -H 'accept: application/json'
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code title="Java-Unirest" fullWidth="false" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://connects.torusdigital.com/api/v1/profitandloss/{cocode}/{reportType}")
  .header("Content-Type", "application/json")
  .asString();
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code title="Go-Native" overflow="wrap" lineNumbers="true" fullWidth="true" %}

```go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
)

func main() {
	url := "https://connects.torusdigital.com/api/v1/profitandloss/{cocode}/{reportType}"
	method := "GET"

	client := &http.Client{}
	req, err := http.NewRequest(method, url, nil)

	if err != nil {
		fmt.Println(err)
		return
	}
	req.Header.Add("Content-Type", "application/json")

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(body))
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code title="JavaScript-jQuery" overflow="wrap" lineNumbers="true" %}

```javascript
var settings = {
  "url": "https://connects.torusdigital.com/api/v1/profitandloss/{cocode}/{reportType}",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response**

```json
[
  {
    "COLUMNNAME": "Total Revenue",
    "YearData": {
      "Y202003": 350519,
      "Y202103": 260485,
      "Y202203": 437575,
      "Y202303": 550496,
      "Y202403": 546662
    }
  },
  {
    "COLUMNNAME": "Total Expenses",
    "YearData": {
      "Y202003": 305958,
      "Y202103": 237577,
      "Y202203": 390789,
      "Y202303": 496378,
      "Y202403": 491389
    }
  },
  {
    "COLUMNNAME": "Profit Before Tax",
    "YearData": {
      "Y202003": 40316,
      "Y202103": 27212,
      "Y202203": 46786,
      "Y202303": 54118,
      "Y202403": 55273
    }
  },
  {
    "COLUMNNAME": "Profit After Tax",
    "YearData": {
      "Y202003": 30903,
      "Y202103": 31944,
      "Y202203": 39084,
      "Y202303": 43002,
      "Y202403": 42042
    }
  },
  {
    "COLUMNNAME": "Operating Profit after Depreciation",
    "YearData": {
      "Y202003": 56666,
      "Y202103": 39119,
      "Y202203": 55909,
      "Y202303": 66751,
      "Y202403": 68703
    }
  }
]
```

**Response Parameter**

<table><thead><tr><th width="172">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>COLUMNNAME</td><td>Describes the financial metric (e.g., Total Revenue, Total Expenses, Profit Before Tax, etc.).</td></tr><tr><td>YearData</td><td>A key-value pair containing the year (<code>Yyyyy03</code>) as the key and the corresponding financial value.</td></tr><tr><td>Y20XX03</td><td>Financial data for the fiscal year ending in March 20XX.</td></tr></tbody></table>


---

# 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://heytorus.gitbook.io/historical-data/profit-and-loss.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.
