# Datasets ## List all datasets `client.Datasets.List(ctx) (*DatasetList, error)` **get** `/api/v1/datasets` List all datasets ### Returns - `type DatasetList struct{…}` List of all available datasets. - `Datasets []Dataset` Array of dataset metadata objects - `ID string` Dataset UUID - `InsertedAt Time` Creation timestamp (UTC) - `Name string` Human-readable dataset name - `Slug string` URL-friendly identifier - `UpdatedAt Time` Last update timestamp (UTC) - `Attribution string` Required attribution text - `Description string` Dataset description - `License string` License identifier (e.g. CC-BY-4.0) - `SourceURL string` URL of the original data source ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) datasetList, err := client.Datasets.List(context.TODO()) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", datasetList.Datasets) } ``` #### Response ```json { "datasets": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ] } ``` ## Create a new dataset (admin only) `client.Datasets.New(ctx, body) (*Dataset, error)` **post** `/api/v1/datasets` Create a new dataset (admin only) ### Parameters - `body DatasetNewParams` - `Name param.Field[string]` Human-readable dataset name - `Slug param.Field[string]` URL-friendly identifier (lowercase, hyphens, no spaces) - `Attribution param.Field[string]` Required attribution text - `Description param.Field[string]` Dataset description - `License param.Field[string]` License identifier (e.g. CC-BY-4.0) - `SourceURL param.Field[string]` Source data URL ### Returns - `type Dataset struct{…}` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `ID string` Dataset UUID - `InsertedAt Time` Creation timestamp (UTC) - `Name string` Human-readable dataset name - `Slug string` URL-friendly identifier - `UpdatedAt Time` Last update timestamp (UTC) - `Attribution string` Required attribution text - `Description string` Dataset description - `License string` License identifier (e.g. CC-BY-4.0) - `SourceURL string` URL of the original data source ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) dataset, err := client.Datasets.New(context.TODO(), githubcomplazafyiplazago.DatasetNewParams{ Name: githubcomplazafyiplazago.F("NYC Bike Lanes"), Slug: githubcomplazafyiplazago.F("nyc-bike-lanes"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dataset.ID) } ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ``` ## Get dataset by ID `client.Datasets.Get(ctx, id) (*Dataset, error)` **get** `/api/v1/datasets/{id}` Get dataset by ID ### Parameters - `id string` ### Returns - `type Dataset struct{…}` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `ID string` Dataset UUID - `InsertedAt Time` Creation timestamp (UTC) - `Name string` Human-readable dataset name - `Slug string` URL-friendly identifier - `UpdatedAt Time` Last update timestamp (UTC) - `Attribution string` Required attribution text - `Description string` Dataset description - `License string` License identifier (e.g. CC-BY-4.0) - `SourceURL string` URL of the original data source ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) dataset, err := client.Datasets.Get(context.TODO(), "id") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dataset.ID) } ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ``` ## Delete a dataset `client.Datasets.Delete(ctx, id) error` **delete** `/api/v1/datasets/{id}` Delete a dataset ### Parameters - `id string` ### Example ```go package main import ( "context" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) err := client.Datasets.Delete(context.TODO(), "id") if err != nil { panic(err.Error()) } } ``` ## Query features in a dataset `client.Datasets.Features(ctx, id, query) (*FeatureCollection, error)` **get** `/api/v1/datasets/{id}/features` Query features in a dataset ### Parameters - `id string` - `query DatasetFeaturesParams` - `Cursor param.Field[string]` Cursor for pagination - `Limit param.Field[int64]` Maximum results - `OutputBuffer param.Field[float64]` Buffer geometry by meters - `OutputCentroid param.Field[bool]` Replace geometry with centroid - `OutputFields param.Field[string]` Comma-separated property fields to include - `OutputGeometry param.Field[bool]` Include geometry (default true) - `OutputInclude param.Field[string]` Extra computed fields: bbox, distance, center - `OutputPrecision param.Field[int64]` Coordinate decimal precision (1-15, default 7) - `OutputSimplify param.Field[float64]` Simplify geometry tolerance in meters - `OutputSort param.Field[string]` Sort by: distance, name, osm_id ### Returns - `type FeatureCollection struct{…}` GeoJSON FeatureCollection (RFC 7946). For paginated endpoints, metadata is returned in HTTP response headers rather than the body: | Header | Description | | --------------- | ------------------------------------------------ | | `X-Limit` | Requested result limit | | `X-Has-More` | `true` if more results exist | | `X-Next-Cursor` | Opaque cursor for next page (cursor pagination) | | `X-Next-Offset` | Numeric offset for next page (offset pagination) | | `Link` | RFC 8288 `rel="next"` link to the next page | Content-Type is `application/geo+json`. - `Features []GeoJsonFeature` Array of GeoJSON Feature objects - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties map[string, unknown]` OSM tags flattened as key-value pairs, plus `@type` (node/way/relation) and `@id` (OSM ID) metadata fields. May include `distance_m` for proximity queries. - `Type GeoJsonFeatureType` Always `Feature` - `const GeoJsonFeatureTypeFeature GeoJsonFeatureType = "Feature"` - `ID string` Compound identifier in `type/osm_id` format - `Type FeatureCollectionType` Always `FeatureCollection` - `const FeatureCollectionTypeFeatureCollection FeatureCollectionType = "FeatureCollection"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) featureCollection, err := client.Datasets.Features( context.TODO(), "id", githubcomplazafyiplazago.DatasetFeaturesParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", featureCollection.Features) } ``` #### Response ```json { "features": [ { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "@id": "bar", "@type": "bar", "amenity": "bar", "cuisine": "bar", "name": "bar" }, "type": "Feature", "id": "node/21154906" } ], "type": "FeatureCollection" } ``` ## Domain Types ### Dataset - `type Dataset struct{…}` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `ID string` Dataset UUID - `InsertedAt Time` Creation timestamp (UTC) - `Name string` Human-readable dataset name - `Slug string` URL-friendly identifier - `UpdatedAt Time` Last update timestamp (UTC) - `Attribution string` Required attribution text - `Description string` Dataset description - `License string` License identifier (e.g. CC-BY-4.0) - `SourceURL string` URL of the original data source ### Dataset List - `type DatasetList struct{…}` List of all available datasets. - `Datasets []Dataset` Array of dataset metadata objects - `ID string` Dataset UUID - `InsertedAt Time` Creation timestamp (UTC) - `Name string` Human-readable dataset name - `Slug string` URL-friendly identifier - `UpdatedAt Time` Last update timestamp (UTC) - `Attribution string` Required attribution text - `Description string` Dataset description - `License string` License identifier (e.g. CC-BY-4.0) - `SourceURL string` URL of the original data source