---
# System prepended metadata

title: Kindling Backend API

---

# Kindling Backend API


## Getting Eligible Trees
The GET call will take in parameters that are a coordinate location and a radius in miles. (or kilometers we just need to pick one)
```
curl -X GET api/all-trees?latitude=40.0000&longitude=-72.0000&radius=0.25
```
This will return a list a of the frontend tree objects in the radius with bios appended.
`Status 200`
```
[
{
 "tree_id": 123456,
 ...
}
]
```
Should this be a subset of all of the trees in a given area? (maybe 10-15 trees)


## Selected Trees

### Updating Selected Trees

The POST call will take a frontend tree object.

```
curl -x POST api/selected-trees -d {"tree_id": 123456, "latitude": 40.0000, "longitude": -72.0000,...}
```
This will return
`Status 201`

Should we pass the whole tree object as opposed to just the coordinates? (Yes this means the frontend only have to deal with one type of tree object)

### Getting a List of Selected Trees

The GET call will return a list of all of the trees that have been selected.

```
curl -x GET api/selected-trees
```

The will return a list of frontend tree objects.
`Status 200`
```
[
{
 "tree_id": 123456,
 "latitude": 40.0000,
 "longitude": -72.0000,
 ...
},
...
]
```

## Getting A Random Tree
The GET call will return a random tree from any of the trees in the data set.
```
curl -X GET api/random-tree
```
This will return a frontend tree object.
`Status 200`
```
{
 "tree_id": 123456,
 ...
]
```
Tip: Pass all tree handler as a pointer and create a point function that returns a random tree.

## Tree Object
A tree object will be formatted thusly:

```js
{
    "tree_id": UID,
    "species_id": 23,
    
    "common_name": "Red Maple",
    "latin_name": "Acer rubrum",
    "name": "Kevin",
    "bio": "...",
    
    "selected": false,
    
    "latitude": 40.0000,
    "longitude": -72.0000,
    
    "features": {
        "diameter": 43, 
        "has_lights": false,
        "has_shoes": true,
        "root_problem": false,
        "has_guards": true,
        "introverted": false, // based on if it has stewards or not
        "zipcode": 11205,
        "neighborhood": "Bedstuy",
        "address": "123 Fake st"
    }
}
```