# Get experiment by id

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

Get experiment by id

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

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Get experiment by id
  version: endpoint_experiments.getExperimentById
paths:
  /v1/private/experiments/{id}:
    get:
      operationId: get-experiment-by-id
      summary: Get experiment by id
      description: Get experiment by id
      tags:
        - - subpackage_experiments
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Experiment resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Experiment_Public'
        '404':
          description: Not found
          content: {}
components:
  schemas:
    JsonListStringPublicOneOf1Items:
      type: object
      properties: {}
    JsonListStringPublic1:
      type: array
      items:
        $ref: '#/components/schemas/JsonListStringPublicOneOf1Items'
    JsonListString_Public:
      oneOf:
        - type: object
          additionalProperties:
            description: Any type
        - $ref: '#/components/schemas/JsonListStringPublic1'
        - type: string
    ExperimentPublicType:
      type: string
      enum:
        - value: regular
        - value: trial
        - value: mini-batch
    FeedbackScoreAverage_Public:
      type: object
      properties:
        name:
          type: string
        value:
          type: number
          format: double
      required:
        - name
        - value
    Comment_Public:
      type: object
      properties:
        id:
          type: string
          format: uuid
        text:
          type: string
        created_at:
          type: string
          format: date-time
        last_updated_at:
          type: string
          format: date-time
        created_by:
          type: string
        last_updated_by:
          type: string
      required:
        - text
    PercentageValues_Public:
      type: object
      properties:
        p50:
          type: number
          format: double
        p90:
          type: number
          format: double
        p99:
          type: number
          format: double
    ExperimentPublicStatus:
      type: string
      enum:
        - value: running
        - value: completed
        - value: cancelled
    ExperimentScore_Public:
      type: object
      properties:
        name:
          type: string
        value:
          type: number
          format: double
      required:
        - name
        - value
    PromptVersionLink_Public:
      type: object
      properties:
        id:
          type: string
          format: uuid
        commit:
          type: string
        prompt_id:
          type: string
          format: uuid
        prompt_name:
          type: string
      required:
        - id
    DatasetVersionSummary_Public:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier of the version
        version_hash:
          type: string
          description: Hash of the version content
        version_name:
          type: string
          description: Sequential version name formatted as 'v1', 'v2', etc.
        change_description:
          type: string
          description: Description of changes in this version
        tags:
          type: array
          items:
            type: string
          description: Tags associated with this version
    Experiment_Public:
      type: object
      properties:
        id:
          type: string
          format: uuid
        dataset_name:
          type: string
        dataset_id:
          type: string
          format: uuid
        project_id:
          type: string
          format: uuid
        project_name:
          type: string
        name:
          type: string
        metadata:
          $ref: '#/components/schemas/JsonListString_Public'
        tags:
          type: array
          items:
            type: string
        type:
          $ref: '#/components/schemas/ExperimentPublicType'
        optimization_id:
          type: string
          format: uuid
        feedback_scores:
          type: array
          items:
            $ref: '#/components/schemas/FeedbackScoreAverage_Public'
        comments:
          type: array
          items:
            $ref: '#/components/schemas/Comment_Public'
        trace_count:
          type: integer
          format: int64
        created_at:
          type: string
          format: date-time
        duration:
          $ref: '#/components/schemas/PercentageValues_Public'
        total_estimated_cost:
          type: number
          format: double
        total_estimated_cost_avg:
          type: number
          format: double
        usage:
          type: object
          additionalProperties:
            type: number
            format: double
        last_updated_at:
          type: string
          format: date-time
        created_by:
          type: string
        last_updated_by:
          type: string
        status:
          $ref: '#/components/schemas/ExperimentPublicStatus'
        experiment_scores:
          type: array
          items:
            $ref: '#/components/schemas/ExperimentScore_Public'
        prompt_version:
          $ref: '#/components/schemas/PromptVersionLink_Public'
        prompt_versions:
          type: array
          items:
            $ref: '#/components/schemas/PromptVersionLink_Public'
        dataset_version_id:
          type: string
          format: uuid
          description: >-
            ID of the dataset version this experiment is linked to. If not
            provided at creation, experiment will be automatically linked to the
            latest version.
        dataset_version_summary:
          $ref: '#/components/schemas/DatasetVersionSummary_Public'
      required:
        - dataset_name

```

## SDK Code Examples

```python
import requests

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

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/experiments/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/experiments/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/experiments/id")

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

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

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

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

```php
<?php

$client = new \GuzzleHttp\Client();

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

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

```csharp
var client = new RestClient("http://localhost:5173/api/v1/private/experiments/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/experiments/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()
```