Geometry API Documentation

The Geometry API allows you to create, retrieve, and manage geometries (polygons) in GeoJSON format.

Authentication: All API endpoints require an API key to be passed in the X-API-Key header.

List Geometries

Endpoint
`GET` /api/geometry/
Description

Get all geometries for the authenticated user in GeoJSON format.

Headers
Name Required Description
X-API-Key Yes Your API key in UUID format
Response

Returns a GeoJSON FeatureCollection containing all geometries.

Example Response (200 OK)
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [[[lon1, lat1], [lon2, lat2], ...]]
      },
      "properties": {
        "id": "uuid-string",
        "name": "Farm 1",
        "area": 12345.67,
        "created_at": "2023-01-01T12:00:00Z"
      }
    },
    ...
  ]
}
Error Responses
Status Code Description
401 Unauthorized - Missing API key
403 Forbidden - Invalid API key
500 Internal Server Error

Create Geometry

Endpoint
POST /api/geometry/
Description

Create a new geometry with name and polygon data.

Headers
Name Required Description
X-API-Key Yes Your API key in UUID format
Content-Type Yes application/json
Request Body
Parameter Type Required Description
name string Yes Name of the geometry
geometry object Yes Geometry in GeoJSON format
Example Request
{
  "name": "Farm 1",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [longitude1, latitude1],
        [longitude2, latitude2],
        [longitude3, latitude3],
        [longitude1, latitude1]
      ]
    ]
  }
}
Response

Returns the created geometry object with id, name, geometry, and created_at.

Example Response (201 Created)
{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[lon1, lat1], [lon2, lat2], ...]]
  },
  "properties": {
    "id": "uuid-string",
    "name": "Farm 1",
    "area": 12345.67,
    "created_at": "2023-01-01T12:00:00Z"
  }
}
Error Responses
Status Code Description
400 Bad Request - Invalid parameters
401 Unauthorized - Missing API key
403 Forbidden - Invalid API key
500 Internal Server Error

Get Specific Geometry

Endpoint
GET /api/geometry/{id}/
Description

Get a specific geometry by UUID in GeoJSON format.

Path Parameters
Parameter Type Required Description
id UUID Yes UUID of the geometry
Headers
Name Required Description
X-API-Key Yes Your API key in UUID format
Response

Returns a GeoJSON Feature containing the geometry.

Example Response (200 OK)
{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[lon1, lat1], [lon2, lat2], ...]]
  },
  "properties": {
    "id": "uuid-string",
    "name": "Farm 1",
    "area": 12345.67,
    "created_at": "2023-01-01T12:00:00Z"
  }
}
Error Responses
Status Code Description
400 Bad Request - Invalid geometry ID format
401 Unauthorized - Missing API key
403 Forbidden - Invalid API key
404 Not Found - Geometry not found
500 Internal Server Error

Delete Geometry

Endpoint
DELETE /api/geometry/{id}/
Description

Delete a specific geometry by UUID.

Path Parameters
Parameter Type Required Description
id UUID Yes UUID of the geometry to delete
Headers
Name Required Description
X-API-Key Yes Your API key in UUID format
Response

Returns 204 No Content on successful deletion.

Error Responses
Status Code Description
400 Bad Request - Invalid geometry ID format
401 Unauthorized - Missing API key
403 Forbidden - Invalid API key or insufficient permissions
404 Not Found - Geometry not found
500 Internal Server Error