# cqGMA Reference Activations API

## Overview

The cqGMA Reference Activations API provides activation history for:

* GMA Summits
* MOTA (Mills)

The API returns:

* Activation date
* Activator callsign
* Number of QSOs
* Total activation count
* Total QSO count

---

# API Key

An API key is required for access.

API keys can be requested via the cqGMA support team:

```text
https://www.cqgma.org/support/contact.html
```

Example API key:

```text
GMA-1234-XXXXXXXXXX
```

---

# API URL

```text
https://www.cqgma.org/api/ref_activations.php
```

---

# Parameters

| Parameter | Description  |
| --------- | ------------ |
| key       | Your API key |
| ref       | Reference    |

---

# Examples

## Summit

```text
https://www.cqgma.org/api/ref_activations.php?key=GMA-1234-XXXXXXXXXX&ref=SO/BI-001
```

## MOTA (Mill)

```text
https://www.cqgma.org/api/ref_activations.php?key=GMA-1234-XXXXXXXXXX&ref=X32835
```

---

# Example Return JSON

```json
{
  "ok": true,
  "ref": "SO/BI-001",
  "name": "Wielka Racza",
  "program": "GMA",
  "type": 0,
  "activation_count": 14,
  "qso_count": 309,
  "activations": [
    {
      "date": "20170923",
      "mycall": "SP9MA/P",
      "qsos": 7
    },
    {
      "date": "20170923",
      "mycall": "SP/HB9BIN/P",
      "qsos": 16
    }
  ]
}
```

---

# Error Messages

## Missing API Key

```json
{
  "ok": false,
  "error": "missing_api_key"
}
```

## Invalid API Key

```json
{
  "ok": false,
  "error": "invalid_api_key"
}
```

## Missing Reference

```json
{
  "ok": false,
  "error": "missing_ref"
}
```

## Unknown Reference

```json
{
  "ok": false,
  "error": "unknown_ref"
}
```

---

# Simple PHP Example

```php
<?php

$key = 'GMA-1234-XXXXXXXXXX';
$ref = 'SO/BI-001';

$url = 'https://www.cqgma.org/api/ref_activations.php?key=' .
       urlencode($key) .
       '&ref=' .
       urlencode($ref);

$json = file_get_contents($url);

$data = json_decode($json, true);

echo 'Activations: ' . $data['activation_count'] . PHP_EOL;
echo 'QSOs: ' . $data['qso_count'] . PHP_EOL;

?>
```

---

# Notes

* References are case-insensitive
* JSON is UTF-8 encoded
* API access requires a valid API key
* One activator on one reference on one day is counted as one activation
* The number of QSOs is calculated from all matching log entries

---

# Contact

CQGMA Website:

```text
https://www.cqgma.org
```

Support:

```text
https://www.cqgma.org/support/contact.html
```
