Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • ClimateScan Documentation ClimateScan Documentation
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Climatescan
  • ClimateScan DocumentationClimateScan Documentation
  • Wiki
  • Projects Nearby List API

Projects Nearby List API · Changes

Page history
Create Projects Nearby List API authored Apr 07, 2021 by Robert de Vries's avatar Robert de Vries
Hide whitespace changes
Inline Side-by-side
Projects-Nearby-List-API.md 0 → 100644
View page @ abba2c03
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
Clone repository
  • Category List API
  • Projects Create API
  • Projects List API
  • Projects Nearby List API
  • User Login API
  • Home