Dev Examples

What is working

  • creating and getting categories
  • creating and getting things

Does not work

  • authentication (all calls are not authenticated)
  • search

Use examples so far

I am assuming a running Zyre server on localhost:4080

Create a simple structure of types

curl -X POST -d '
{ 
  "name": "Country",
  "description": ""
}' http://localhost:4080/types

curl -X POST -d '
{ 
  "name": "City",
  "description": "City in a Country",
  "parent_id": <enter id of the Country>
}' http://localhost:4080/types

curl -X POST -d '
{ 
  "name": "Statue",
  "description": "Statue in a City",
  "parent_id" : <enter id of the City>
}' http://localhost:4080/types

With each request you will get a current Type in a JSON format.

Now, list all Types:

curl http://localhost:4080/types

And you should get something like this:

[
 {"_id":"4dc26d3c05ed1b2729000002", "description":"", "name":"Country"},
 {"_id":"4dc26ed105ed1b27a1000001", "description":"City in a Country", "name":"City", "parent_id":"4dc26d3c05ed1b2729000002"},
 {"_id":"4dc26f4a05ed1b27a0000001", "description":"Statue in a City", "name":"Statue", "parent_id":"4dc26ed105ed1b27a1000001"}]

Your IDs might differ though.

You can also fetch individual objects:

curl http://localhost:4080/types/4dc26d3c05ed1b2729000002

Fill database with Things.

Below use the IDs of the categories

curl -X POST -d '
{
  "name": "Poland",
  "description": "Poland, officially the Republic of Poland, is a country in Central Europe bordered by Germany to the west; the Czech Republic and Slovakia to the south; Ukraine, Belarus and Lithuania to the east; and the Baltic Sea and Kaliningrad Oblast, a Russian exclave, to the north.",
  "type_id": <fill type_id of Country>,
  "location": [52.216667, 21.033333]
}' http://localhost:4080/things/

curl -X POST -d '
{
  "name": "Toruń",
  "description": "Toruń is an ancient city in northern Poland, on the Vistula River.",
  "type_id": <fill type_id of City>,
  "location": [53.033333, 18.616667]
}' http://localhost:4080/things

curl -X POST -d '
{
  "name": "Nicolaus Copernicus statue",
  "description": "The monument presents Copernicus in academic dress. His left hand holds an astrolabe, and his right index finger points to the heavens. This symbolizes Copernicus connection with astronomy and celestial studies. The monument is surrounded by stone benches and an adjoining stone water well.",
  "location": [53.010278, 18.605],
  "type_id": <fill type_id of Statue>
}' http://localhost:4080/things

Now list all the things:

curl http://localhost:4080/things
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License