# Business Fields

- Sandbox: `GET https://sandbox.payme.io/api/business-fields`
- Production: `GET https://live.payme.io/api/business-fields`

## Credentials

No credentials are documented for this endpoint.

## Overview
This API endpoint retrieves a list of business fields, allowing users to sort and filter the data based on specific criteria.

## Endpoint
`GET /api/business-fields`

## Description
This endpoint provides access to a collection of business fields. It supports sorting by local name in either ascending or descending order.

## Request Parameters

- `sort_by`: Specifies the field by which the results should be sorted. In this case, it can be set to `name_local` for sorting by the local name of the business fields.
- `sort_direction`: Determines the order of sorting. It accepts two values:
  - `asc` for ascending order.
  - `desc` for descending order.

## Headers

- `PayMe-Partner-Key`: This should be set to `payme` to authenticate the request.

## Query Example
```http
GET /api/business-fields?sort_by=name_local&sort_direction=desc HTTP/1.1
Host: test11.payme.io
PayMe-Partner-Key: payme
```

## Response Structure

- `status_code`: Indicates the status of the request. A value of `0` typically means success.
- `page`: The current page number of the results.
- `items_per_page`: The number of items per page.
- `items_total`: The total number of items available.
- `language`: The language of the returned data, indicated here as "he" (Hebrew).
- `items`: A collection of business fields, where each field is represented as an object with the following properties:
  - `code`: A unique identifier for the business field.
  - `name_intl`: The international name of the business field.
  - `name_local`: The local name of the business field.

### Response Example
```json
{
    "status_code": 0,
    "page": 1,
    "items_per_page": 245,
    "items_total": 245,
    "language": "he",
    "items": {
        "244": {
            "code": 10565,
            "name_intl": "Shutters",
            "name_local": "תריסים"
        }
    }
}
```

## Error Handling
In case of an error, the response will include a non-zero `status_code` and may include additional fields describing the error.

## Notes
- Ensure that the `PayMe-Partner-Key` header is included in each request for successful authentication.
- The sort and filter capabilities of this endpoint can help in organizing and retrieving specific business field information efficiently.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

```json
GET /api/business-fields?sort_by=name_local&sort_direction=desc HTTP/1.1
Host: test11.payme.io
PayMe-Partner-Key: payme
```

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/business-fields' \
  -H 'Content-Type: application/json' \
  --data-raw '{}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/business-fields", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({}),
});

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

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/business-fields",
    json={},
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/business-fields');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### default — Default (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | integer |  |
| `page` | integer |  |
| `items_per_page` | integer |  |
| `items_total` | integer |  |
| `language` | string |  |
| `items` | object |  |
| `items.244` | object |  |
| `items.244.code` | integer |  |
| `items.244.name_intl` | string |  |
| `items.244.name_local` | string |  |

```json
{
  "status_code": 0,
  "page": 1,
  "items_per_page": 245,
  "items_total": 245,
  "language": "he",
  "items": {
    "244": {
      "code": 10565,
      "name_intl": "Shutters",
      "name_local": "תריסים"
    }
  }
}
```
