From WeoGeo Support

Contents

WeoGeo APIs

Datasets API

Third Party Developer Documentation >> Developer: API >> Datasets API

List Datasets

GET /datasets.weo

Returns a list of relevant datasets.

Standard parameters:

  • page: desired page number, defaults to 1
  • per_page: number of datasets per page, defaults to 15
  • north, south, east, and west: the bounding box coordinates for the region of interest, in Geographic WGS84

Optional filter parameters:

  • parents_of: dataset token which limits results to it's direct parents
  • children_of: dataset token which limits results to it's direct children
  • price_min: the minimum price for the dataset
  • price_max: the maximum price for the dataset
  • date_from: the oldest date of dataset creation, format: yyyy-mm-dd (data_created_on in the weofile)
  • date_to: the newest date of dataset creation, format: yyyy-mm-dd (data_created_on in the weofile)
  • date_type: the desired data type (either "RASTER", "VECTOR", or "OTHER")
  • min_provider_rating: the minimum average rating for the provider (0 to 5)
  • min_dataset_rating: the minimum average rating for the dataset
  • tags: space delimited array of tags to match against

Example:

Sample call retrieving the first 15 datasets that intersects the region of interest (north=90, south=0,east=0, west=-180) from the WeoGeo Market:

Request

curl -H 'Content-Type: application/xml' http://#{hostname}/datasets.weo?page=1&east=0&north=90&south=0&west=-180&scale=5


Response

 Status: 200 OK
 <datasets total_entries="200" current_page="1" per_page="15" total_pages="14">
   <dataset>
     ...
   </dataset>
   <dataset>
     ...
   </dataset>
 </datasets>

Notes:

  • This call can be executed to return as WEO (XML), JSON, or RSS response, depending on the specified extension.
  • Login credentials are not required on the market.
  • Login credentials are required on a library. The results will be scoped to datasets that are accessible to the current user.
  • These calls will deliver a lot of information about each data set. Determining which bits of information to expose to the toolbar's users will take some planning. Common used fields include: short_name, long_name, dataset_ranking, dataset_votes, date_collected, uploaded_at, primary_tag, data_type, datum, projection, and description.
  • The boundaries of the API calls should be derived from the active workspace of the user. If the user is working on data that covers the New York City Metro area, the Library or Market browse request should focus on this area too.

Get Dataset as WeoFile

GET /datasets/#{token}.weo

Returns the WeoFile for the supplied dataset/listing token.

Request through curl:

curl -u #{api_key}: -H 'Content-Type: application/xml' http://#{hostname}/datasets/#{token}.weo

Response:

<dataset>
<token>82b4bce8c70ab01609aedbc71215b1b</token>
...
<short_name>Portland</short_name> 
...
</dataset>

Get Dataset as KML

GET /dataset/#{token}.kml

Returns dataset details for the supplied token as Markup Language (KML)

Request through curl:

curl -u #{api_key}: -H 'Content-Type:application/xml' http://#{hostname}/datasets/#{token}.kml

Response:

 <?xml version="1.0" encoding="UTF-8"?>
 <kml xsi:schemaLocation="http://earth.google.com/kml/2.2  
   http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd"  
   xmlns:atom="http://www.w3.org/2005/Atom"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xmlns="http://www.opengis.net/kml/2.2">
   ...
 </kml>

Create a Dataset

Dataset Creation Workflow

The currently recommended workflow for creation of datasets via the API:

Generate Tokens

POST /datasets/tokens

Generates a dataset that is empty(except for it's token) and returns the token.

Options

  • count: quantity of tokens you wish to generate, defaults to 1.

Request

curl -u #{api_key}: -X POST https://#{hostname}/datasets/tokens?count=2

Response

   b7182f39-a8c3-e154-a943-6dbeaaf1d1ab
   e0b4c67d-c7e9-bf59-a4bb-608736d4cfe0


Update a Dataset

PUT /datasets/#{token}.weo

Updates an existing dataset with new details from the submitted XML. If the dataset update fails, XML will be returned with an list of all of the errors that need to be corrected before it can be successfully saved.

Options

  • validate=true - Passing this parameter with your request will cause the weo file to be validated with out actually saving it. This is useful for debugging scripts and applications.

Request

curl -u #{api_key}: -X PUT -H 'Content-Type: application/xml' -d @#{path_to_weofile} https://#{hostname}/datasets/#{token}.weo
 <dataset>
   ...
 </dataset>

Response

 Status: 200 OK

Destroy a Dataset

DELETE /datasets/#{token}.weo

Destroys the dataset at the referenced URL.

Request

curl -u #{api_key}: -X DELETE http://#{hostname}/datasets/#{token}.weo

Response

 Status: 200 OK
Page History