|
|
The Projects Nearby List API can be used to fetch a list of ClimateScan projects nearby a given location. Authorization for this endpoint is not required.
|
|
|
|
|
|
| Attribute | Value |
|
|
|
| --- | --- |
|
|
|
| URL | https://www.climatescan.org/api/v1/projects/nearby |
|
|
|
| Supported methods | `GET` |
|
|
|
| Authorization required | No |
|
|
|
| Response type | JSON |
|
|
|
|
|
|
## Request
|
|
|
|
|
|
The Projects Nearby List API is idempotent and therefor only accepts the GET method. The location data can be submitted by way of URL query params. Please refer to the following table for the supported list of query params.
|
|
|
|
|
|
| Query param | Type | Description | Example value |
|
|
|
| ----------- | --------- | ------------------------- | ------------- |
|
|
|
| `lat` | `Decimal` | Location latitude value. | `53.1764` |
|
|
|
| `lon` | `Decimal` | Location longitude value. | `6.9724` |
|
|
|
|
|
|
For example, given the latitude `53.1764` and longitude `6.9724`:
|
|
|
|
|
|
```
|
|
|
GET https://www.climatescan.org/api/v1/projects/nearby?lat=53.1764&lon=6.9724
|
|
|
```
|
|
|
|
|
|
In JavaScript, the request would look as follows.
|
|
|
|
|
|
```javascript
|
|
|
fetch('https://www.climatescan.org/api/v1/projects/nearby?lat=53.1764&lon=6.9724')
|
|
|
.then(res => res.json());
|
|
|
```
|
|
|
|
|
|
## Response
|
|
|
|
|
|
The Projects Nearby List API will always return a JSON-encoded list of exactly 10 projects near the user's location. The list is automatically ordered by distance. The project with the least distance to the user location is provided as the first result.
|
|
|
|
|
|
The list of projects can, for example, be shown in a dropdown menu or on a map.
|
|
|
|
|
|
Each entry in the response body is structured as follows.
|
|
|
|
|
|
| Attribute | Type | Description | Example value |
|
|
|
| --------- | ---- | ----------- | ------------- |
|
|
|
| `id` | `int` | ID of the project. | `"1128"` |
|
|
|
| `latitude` | `Decimal` | Latitude of the project location. | `"53.1886"` |
|
|
|
| `longitude` | `Decimal` | Longitude of the project location. | `"6.95661"` |
|
|
|
| `title` | `str` | Title of the project. | `"Groen dak ziekenhuis Ommelander"` |
|
|
|
| `distance_km` | `Decimal` | The distance in kilometers from the provided location to the project's location. | `"1.7165"` |
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
```json
|
|
|
HTTP/2 200
|
|
|
Content-Type: application/json
|
|
|
|
|
|
[
|
|
|
{
|
|
|
"id": "1128",
|
|
|
"latitude": "53.1886",
|
|
|
"longitude": "6.95661",
|
|
|
"title": "Groen dak ziekenhuis Ommelander",
|
|
|
"distance_km": "1.7165819419633226"
|
|
|
}, {
|
|
|
"id": "5595",
|
|
|
"latitude": "53.171",
|
|
|
"longitude": "7.0294",
|
|
|
"title": "Blauwestad - Water Retention",
|
|
|
"distance_km": "3.845773889264074"
|
|
|
},
|
|
|
...
|
|
|
]
|
|
|
```
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
* Please note that there is no limit to the distance between the provided location, and a project's location. The Projects Nearby List API will *always* return a list of 10 items, even if the distance of those projects is thousands of kilometers away from the provided location. |
|
|
\ No newline at end of file |