# Seed API

Currently seed node address are fixed as `http://api.Fiesta4Spectrum.org:8000` for App1 and `http://api.Fiesta4Spectrum.org:8001` for App2.

## Register to seed node

<mark style="color:green;">`POST`</mark> `http://seed_addr:port/register`

Each miner node needs to register itself to seed node periodically to make itself popular

#### Request Body

| Name                                     | Type   | Description                                       |
| ---------------------------------------- | ------ | ------------------------------------------------- |
| "name"<mark style="color:red;">\*</mark> | String | unique id of the miner                            |
| "addr"<mark style="color:red;">\*</mark> | String | miner's address with port, starts with "http\://" |

{% tabs %}
{% tab title="200: OK with latest application seed returned" %}

```javascript
{
    "seed_name": name_of_seed,
    "from": name_of_seed_node,
    "seedWeight": seed_weight_for_machine_learning,
    "para": {
        "alpha": mixing_weight_when_global_integeration,
	"preprocPara": {
		"avg": list_of_avg_double,
		"std": list_of_std_double
		},
	"trainPara": {
		"batch": local_training_batch_size,
		"lr": learning_rate,
		"opt": optimization_algorithm,
		"epoch": local_training_epoch_num,
		"loss": local_training_loss_func,
		},
	"samplePara": {
		"center_freq": center_frequency_int,
		"bandwidth": bandwidth_int,
		},
	"layerStructure": a_list_describe_layer_structure,
	"difficulty": prove_of_work_difficulty
	},
    "peers": list_of_peer_miners
}
```

{% endtab %}
{% endtabs %}

## Fetch the list of all miners alive

<mark style="color:blue;">`GET`</mark> `http://seed_addr:port/miner_peers`

{% tabs %}
{% tab title="200: OK with a list of peer miners returned" %}

```javascript
{
    "peers" : [list_of_addr_strings]
}
```

{% endtab %}
{% endtabs %}

## Get the reward of one node

<mark style="color:blue;">`GET`</mark> `http://seed_addr:port/reward`

#### Query Parameters

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| "id" | String | the unique id of the node |

{% tabs %}
{% tab title="200: OK with the reward of the given-id device returned" %}

```javascript
{ 
    "id" : id_string,
    "role" : category_string,
    "uploads" : uploads_int,
    "reward" : reward_double
}
```

{% endtab %}
{% endtabs %}
