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

# Samples API

## Samples index

Endpoints \[`GET`]:

| Endpoint                                 | Beschrijving                            |
| ---------------------------------------- | --------------------------------------- |
| `/api/[app_id]/samples.json`             | Dit geeft **ALLE** sampletypes terug    |
| `/api/[app_id]/samples/performance.json` | Dit geeft **performance**-samples terug |
| `/api/[app_id]/samples/errors.json`      | Dit geeft **error**-samples terug       |

Parameters:

| Param       | Type              |                                    Beschrijving |
| ----------- | ----------------- | ----------------------------------------------: |
| action\_id  | string            |      Voorbeeld: `BlogPostsController-hash-show` |
| exception   | string            |                        Voorbeeld: NoMethodError |
| since       | timestamp/integer |                            Alle tijden zijn UTC |
| before      | timestamp/integer |                            Alle tijden zijn UTC |
| limit       | integer           |  Het aantal teruggegeven entries (standaard 10) |
| count\_only | boolean           | (true/false) Om alleen een count terug te geven |

Escape actions door te vervangen:

* `#` met `-hash-`
* `/` met `-slash-`
* `.` met `-dot-`

Dus `BlogPostsController#show` wordt: `BlogPostsController-hash-show`

Een voorbeeld van een volledige request zou zijn:

```shell Shell theme={null}
https://appsignal.com/api/5114f7e38c5ce90000000011/samples.json?token=HseUe&action_id=AccountsController-hash-index&exception=ActionView::Template::Error&since=1374843246
```

### Resultaat

Dit endpoint geeft de volgende JSON terug (een trage sample en een errorsample):

<CodeGroup>
  ```json JSON theme={null}
  {
    "count": 2,
    "log_entries": [
      {
        "id": "51f29e7b183d700800150358_SlowController#show_1476962400",
        "action": "SlowController#show",
        "path": "/slow-request",
        "duration": 3182.545407,
        "status": 200,
        "time": 1476962400,
        "is_exception": false,
        "exception": {
          "name": null
        }
      },
      {
        "id": "57f653fa16b7e24cb0dc9e2b_ErrorController#trigger_1475761080",
        "action": "ErrorController#trigger",
        "path": "/error-request",
        "duration": null,
        "status": null,
        "time": 1475761080,
        "is_exception": true,
        "exception": {
          "name": "ActionView::Template::Error"
        }
      }
    ]
  }
  ```
</CodeGroup>

## Samples show

Endpoint \[`GET`]: `/api/[app_id]/samples/[id].json`

Parameters:

| Param | Type   |                                                                                        Beschrijving |
| ----- | ------ | --------------------------------------------------------------------------------------------------: |
| id    | string | Gesanitiseerd sample-id (voorbeeld: `51f29e7b183d700800150358_SlowController-hash-show_1476962400`) |

### Resultaat

Dit is een **SLOW** log entry:

<CodeGroup>
  ```json JSON theme={null}
  {
    "id": "51f29e7b183d700800150358_SlowController#show_1476962400",
    "action": "slow#request",
    "db_runtime": 500.0,
    "duration": 300.0,
    "environment": {},
    "hostname": "app1",
    "is_exception": null,
    "kind": "http_request",
    "params": {},
    "path": "/blog",
    "request_format": "html",
    "request_method": "GET",
    "session_data": {},
    "status": "200",
    "view_runtime": 500.0,
    "time": 1002700800,
    "end": 978339601,
    "allocation_count": 110101,
    "events": [
        {
            "action": "query",
            "duration": 250.0,
            "group": "mongoid",
            "name": "query.mongoid",
            "payload": {
                "query": "this is a mongoid query"
            },
            "time": 0,
            "end": 0
            "digest": 00000,
            "allocation_count": 1010101

        }
    ],
    "exception": null
  }
  ```
</CodeGroup>

Dit is een **ERROR** log entry:

<CodeGroup>
  ```json JSON theme={null}
  {
    "id": "57f653fa16b7e24cb0dc9e2b_ErrorController#trigger_1475761080",
    "action": "Error#trigger",
    "db_runtime": 500.0,
    "duration": null,
    "environment": {
      "HTTP_USER_AGENT": "Mozilla/5.0 (Macintosh"
    },
    "hostname": "app1",
    "is_exception": true,
    "kind": "http_request",
    "params": {
      "id": 1,
      "get": "something"
    },
    "path": "/blog",
    "request_format": "html",
    "request_method": "GET",
    "session_data": {
      "current_user_id": 1
    },
    "status": "200",
    "view_runtime": 500.0,
    "time": 1002700800,
    "end": 978339601,
    "events": [],
    "tags": {
      "user": "john doe",
      "id": 1
    },
    "exception": {
      "message": "The method was not found",
      "name": "NoMethodError",
      "backtrace": ["Backtrace line 1", "Backtrace line 2", "Backtrace line 3"]
    }
  }
  ```
</CodeGroup>

**Let op:** Als u meer geavanceerde queryfunctionaliteit nodig heeft, zoals het zoeken naar samples op tag, kunt u dat doen met onze [GraphQL API](https://docs.appsignal.com/api/graphql). Bekijk de documentatie van de GraphQL API voor queryvoorbeelden en meer details.
