# Get Parent(s)

## Get one or more parent records

<mark style="color:blue;">`GET`</mark> `https://integrate.d6plus.co.za/api/v1/adminplus/parents/{school_login_id}`

Use this endpoint to fetch one or more parent records for the specified school.  By default, parents of all current active learners will be returned.&#x20;

It is possible to retrieve a single parent by providing the optional `parent_id` query parameter.

#### Path Parameters

| Name                                                | Type    | Description                                      |
| --------------------------------------------------- | ------- | ------------------------------------------------ |
| school\_login\_id<mark style="color:red;">\*</mark> | Integer | The login ID of the school to retrieve data from |

#### Query Parameters

| Name       | Type    | Description                 |
| ---------- | ------- | --------------------------- |
| parent\_id | Integer | The ID of a specific parent |

#### Headers

| Name                                              | Type   | Description       |
| ------------------------------------------------- | ------ | ----------------- |
| HTTP-X-USERNAME<mark style="color:red;">\*</mark> | String | As provided by d6 |
| HTTP-X-PASSWORD<mark style="color:red;">\*</mark> | String | As provided by d6 |

{% tabs %}
{% tab title="200 The request was successful." %}

```json
[
    {
        "id": "40",
        "title": "Mr",
        "first_name": "John James",
        "last_name": "Smith",
        "mobile_calling_code": "27",
        "mobile_number": "0823456789",
        "email_address": "jjsmith@example.com",
        "date_of_birth": "1967-02-14",
        "gender": "M",
        "ethnic_group_id": "4",
        "ethnic_group": "White",
        "residential_address": "Plot 101\r\nDaffodil Street\r\nPretoria",
        "postal_address": "PO Box 12\r\nMenlyn\r\nPretoria",
        "home_language_id": "2",
        "home_language": "English",
        "nationality": "South Africa",
        "family_code": "1001",
        "id_number": "6702145076084",
        "passport_number": "A0176543",
        "marital_status_id": "2",
        "marital_status": "Married",
        "occupation_status": "Full Time Employed",
        "occupation": "Salesman",
        "employment_sector": "Selling",
        "gross_annual_income": "120000.00"
    },
    {
        "id": "41",
        "title": "Mrs",
        "first_name": "Jane Jenny",
        "last_name": "Smith",
        "mobile_calling_code": "27",
        "mobile_number": "0798765432",
        "email_address": "smith.jj@example.org",
        "date_of_birth": "1955-06-17",
        "gender": "F",
        "ethnic_group_id": "1",
        "ethnic_group": "African/Black",
        "residential_address": "Plot 101\r\nDaffodil Street\r\nPretoria",
        "postal_address": "PO Box 12\r\nMenlyn\r\nPretoria",
        "home_language_id": "2",
        "home_language": "English",
        "nationality": "South Africa",
        "family_code": "1001",
        "id_number": "5506170079082",
        "passport_number": "",
        "marital_status_id": "2",
        "marital_status": "Married",
        "occupation_status": "Unemployed",
        "occupation": "",
        "employment_sector": "Other",
        "gross_annual_income": "0.00"
    }
]
```

{% endtab %}

{% tab title="404: Not Found The resource was not found." %}

```json
{
    "error": "Not found",
    "error_description": "No parent records found"
}
```

{% endtab %}

{% tab title="401: Unauthorized The server understood the request, but is refusing it or access is not allowed." %}

```json
{
    "error": "Unauthorized",
    "error_description": "Client access not authorised"
}
```

{% endtab %}

{% tab title="403: Forbidden The server understood the request, but the requested action is not allowed." %}

```json
{
    "error": "Integration not activated",
    "error_description": "Please activate the Admin+ API for this client before making this request"
}
```

{% endtab %}
{% endtabs %}

## Examples

{% tabs %}
{% tab title="PHP" %}

```php
<?php

const BASE_URL = 'https://integrate.d6plus.co.za/api/v1/adminplus/parents';
const SCHOOL_LOGIN_ID = '1000';
const PARAMS = ['parent_id' => 1];
const API_USERNAME = getenv('API_USERNAME'); // Assuming you have these environment variables set
const API_PASSWORD = getenv('API_PASSWORD');

$curl = curl_init();

$query = http_build_query(PARAMS);

$options = [
    CURLOPT_URL => BASE_URL . '/' . SCHOOL_LOGIN_ID . '?' . $query,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        "HTTP-X-USERNAME: " . API_USERNAME,
        "HTTP-X-PASSWORD: " . API_PASSWORD
    ],
];

curl_setopt_array($curl, $options);

$response = curl_exec($curl);

if (curl_errno($curl)) {
    throw new Exception('Curl error: ' . curl_error($curl));
}

curl_close($curl);

echo $response;
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location 'https://integrate.d6plus.co.za/api/v1/adminplus/parents/1000?parent_id=1' \
--header 'HTTP-X-USERNAME: your_username' \
--header 'HTTP-X-PASSWORD: your_password'
```

{% endtab %}
{% endtabs %}
