Skip to content

Commit

Permalink
Merge pull request #2 from sackh/docs
Browse files Browse the repository at this point in the history
Updated example in README.
  • Loading branch information
omanges committed Jul 24, 2020
2 parents c5f16f8 + 52534d5 commit 26e5554
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ The following is a tiny "Hello World"-like example that you can run to have a su

```python
import json
from xyzspaces.apis import HubApi
import xyzspaces as xyz
from geojson import FeatureCollection

xyz = xyz.XYZ(credentials="MY_XYZ_TOKEN")

# Creating a New Space
api = HubApi(credentials="MY_XYZ_TOKEN")
data = {"title": "My Demo Space", "description": "Description as markdown"}
space_id = api.post_space(data=data)["id"]
title = "My Demo Space"
description = "Description as markdown"
space = xyz.spaces.new(title=title, description=description)

# Add a Feature to a Space
features = {
Expand All @@ -118,10 +121,11 @@ features = {
]]
}
}
feature_id = api.put_space_features(space_id=space_id, data=features)["features"][0]["id"]

feature_id = space.add_features(features=FeatureCollection([features]))["features"][0]["id"]

# Reading a Feature from a Space
feature = api.get_space_feature(space_id=space_id, feature_id=feature_id)
feature = space.get_feature(feature_id=feature_id)
print(json.dumps(feature, indent=4, sort_keys=True))
```

Expand Down

0 comments on commit 26e5554

Please sign in to comment.