> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.

# Get view by id

GET http://localhost:5173/api/v1/private/views/{id}

Get a view with its current version

Reference: https://www.comet.com/docs/opik/reference/rest-api/views/get-view-by-id

## Servers

- `http://localhost:5173/api` (Local server, default)
- `https://www.comet.com/opik/api` (Opik Cloud)

## Request

### Path parameters

- `id` (string, required)

## Response

### 200

View resource

- `id` (string, optional)
- `area` (enum, optional)
  - Allowed values: `widget`
- `name` (string, optional)
- `description` (string, optional)
- `current_version` (integer, optional)
- `created_at` (datetime, optional)
- `created_by` (string, optional)
- `last_updated_at` (datetime, optional)
- `last_updated_by` (string, optional)
- `version` (ViewVersion, optional) — An immutable version of a view

## Errors

### 404 Not Found Error

View not found

- `any`

## Types

### ViewVersion

An immutable version of a view

- `view_id` (string, optional)
- `version` (integer, optional)
- `author` (enum, optional)
  - Allowed values: `user`, `ollie`, `agent`
- `summary` (string, optional)
- `type` (enum, optional)
  - Allowed values: `html`
- `engine_version` (integer, optional) — HTML contract version the view was written against
- `inputs` (map from string to ViewInput, optional)
- `libraries` (list of string, optional) — Libraries the host loads before the view runs; omitted when it uses none
- `html` (string, optional)
- `created_at` (datetime, optional)
- `created_by` (string, optional)

### ViewInput

A data source of a view; the host resolves it and passes the result under the input name

- `kind` (enum, required) — Source type
  - Allowed values: `query`
- `query_id` (string, required) — The saved query to run
- `columns` (map from string to string, optional) — The columns the author saw when it ran the query, name to type. Informational

## Examples

**Response**

```json
{
  "id": "string",
  "area": "widget",
  "name": "string",
  "description": "string",
  "current_version": 1,
  "created_at": "2024-01-15T09:30:00Z",
  "created_by": "string",
  "last_updated_at": "2024-01-15T09:30:00Z",
  "last_updated_by": "string",
  "version": {
    "view_id": "string",
    "version": 1,
    "author": "user",
    "summary": "string",
    "type": "html",
    "engine_version": 1,
    "inputs": {},
    "libraries": [
      "string"
    ],
    "html": "string",
    "created_at": "2024-01-15T09:30:00Z",
    "created_by": "string"
  }
}
```

**SDK Code**

```python
import requests

url = "http://localhost:5173/api/v1/private/views/id"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/views/id';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "http://localhost:5173/api/v1/private/views/id"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:5173/api/v1/private/views/id")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("http://localhost:5173/api/v1/private/views/id")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'http://localhost:5173/api/v1/private/views/id');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("http://localhost:5173/api/v1/private/views/id");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/views/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```