# Get Transaction Data

- Sandbox: `POST https://sandbox.payme.io/api/get-transaction-data`
- Production: `POST https://live.payme.io/api/get-transaction-data`

## Credentials

- Header `PayMe-Public-Key` (optional): XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

## Overview

This endpoint enable to get transaction, based on the transaction status, sale status, sale currency and sale payment method.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `PayMe-Public-Key` | header | string | no | XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction_type` | integer | no | Filter the type of the transactions that will be presented. For all the transaction types see [Transaction Types](/guides-and-use-cases-migrated/lists-statuses/transaction-types). |
| `transaction_status` | string | no | Filter the status of the transactions that will be presented. For all the transaction statuses see [Transaction Statuses](/guides-and-use-cases-migrated/lists-statuses/transaction-statuses). |
| `sale_status` | array | no | Filter the status of the sales that will be presented. For all the sale statuses see [Sale Statuses](/guides-and-use-cases-migrated/lists-statuses/sale-statuses). Example: "initial" |
| `sale_currency` | array | no | Sale currency. [3-letter ISO 4217 name](https://en.wikipedia.org/wiki/ISO_4217). Example: "ILS" |
| `sale_payment_method` | array | no | the Payment method used to pay the sale. For all the payment methods see [Available Payment Methods](/payments-migrated/direct-api/available-payment-methods). Example: "credit-card" |

### Request example

```json
{
  "transaction_type": 1,
  "transaction_status": "validated",
  "sale_status": [
    "completed"
  ],
  "sale_currency": [
    "ILS"
  ],
  "sale_payment_method": [
    "credit-card"
  ]
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/get-transaction-data' \
  -H 'Content-Type: application/json' \
  -H 'PayMe-Public-Key: <PayMe-Public-Key>' \
  --data-raw '{
  "transaction_type": 1,
  "transaction_status": "validated",
  "sale_status": [
    "completed"
  ],
  "sale_currency": [
    "ILS"
  ],
  "sale_payment_method": [
    "credit-card"
  ]
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/get-transaction-data", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "PayMe-Public-Key": "<PayMe-Public-Key>",
  },
  body: JSON.stringify({
    "transaction_type": 1,
    "transaction_status": "validated",
    "sale_status": [
      "completed"
    ],
    "sale_currency": [
      "ILS"
    ],
    "sale_payment_method": [
      "credit-card"
    ]
  }),
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/get-transaction-data",
    headers={
        "PayMe-Public-Key": "<PayMe-Public-Key>",
    },
    json={
        "transaction_type": 1,
        "transaction_status": "validated",
        "sale_status": [
            "completed",
        ],
        "sale_currency": [
            "ILS",
        ],
        "sale_payment_method": [
            "credit-card",
        ],
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "transaction_type": 1,
  "transaction_status": "validated",
  "sale_status": [
    "completed"
  ],
  "sale_currency": [
    "ILS"
  ],
  "sale_payment_method": [
    "credit-card"
  ]
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/get-transaction-data');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'PayMe-Public-Key: <PayMe-Public-Key>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | integer | Status of the request (0 - success, 1 - error) |
| `items` | array | The transactions details. |
| `items_count` | integer | Count of the transactions. |

```json
{
  "status_code": 0,
  "items": [],
  "items_count": 0
}
```
