Skip to content

Schema HTTP Actions

Greg Malcolm edited this page May 2, 2016 · 19 revisions

Currently most of the resources available via the API confirm to basic CRUD patterns. When testing out crud operations it may be worth considering testing with the current test server:

http//ed-materializer.herokuapp.com/

When you've tested with the test surver, you can then work with the production server:

http://api.edmaterializer.com

This server will be used for the examples here to avoid accidents.

The API schema is in JSON API format:

http://jsonapi.org/

GET "index" urls

Example:

GET /api/v4/surveys/

Page sizes are currently 500 items (we are probably going to shorten them at some point)

Example through CURL (runnable in git bash or unix):

curl -i -H "Content-Type: application/json" http//ed-materializer.herokuapp.com/api/v4/stars/\?page=1

Query Param Options

Standard paging stuff

  • page
  • per_page (currently defaults to 500)

Filtering attributes vary. These are common options:

  • system
  • commander/updater
  • world
  • updated_before
  • updated_after

Examples:

Filter on updater and world:

curl -i -H "Content-Type: application/json" http//ed-materializer.herokuapp.com/api/v4/stars/?updater=marlon%20blake&world=A&page=1

Find all records after 30th Dec 2015

curl -i -H "Content-Type: application/json" http//ed-materializer.herokuapp.com/api/v4/stars/?updated_after=2015-12-30

GET "show" with ID urls

Example:

GET /api/v4/world_surveys/:id

Currently uses numerical ids

This returns the record where id=600

curl -i -H "Content-Type: application/json" http//ed-materializer.herokuapp.com/api/v4/stars/600

POST record inserts

Note: Requires an access_token. See Auth

Example:

POST /api/v4/worlds

Curl example:

Note: change uid, access_token and client, to use your own auth tokens):

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "access_token: ACCESS_TOKEN" -H "client: CLIENT" -H "uid: jenny@example.com" -X POST -d '{"data":{"type": "worlds", "attributes": {"system-name": "test", "updater": "test", "world": "A", "gravity": "1.3"}}}' http//ed-materializer.herokuapp.com/api/v4/worlds

NOTE: Special "application" role users such as EDDiscovery will also need to submit a "user" param on the root level specifiying the commander name. This is a required field. EG:

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "access_token: ACCESS_TOKEN" -H "client: CLIENT" -H "uid: jenny@example.com" -X POST -d '{"user", "Jameson", "data":{"type": "worlds", "attributes": {"system-name": "test", "updater": "test", "world": "A", "gravity": "1.3"}}}' http//ed-materializer.herokuapp.com/api/v4/worlds

PATCH single record update

Note: Requires an access_token. See Auth

`PATCH /api/v4/worlds/:id'

or if you can't use PATCH for some reason: `PUT /api/v4/worlds/:id'

This example assumes we want to change the record where id=4.

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "access_token: ACCESS_TOKEN" -H "client: CLIENT" -H "uid: jenny@example.com" -X PATCH -d '{"data":{"id": 4, "type": "worlds", "attributes": {"system-name": "test2", "updater": "test", "world": "A 1", "gravity": "3.3"}}}' http//ed-materializer.herokuapp.com/api/v4/worlds/4

If the return code is 204 then you were successful

NOTE: Special "application" role users such as EDDiscovery will also need to submit a "user" param on the root level specifiying the commander name. This is a required field.

DELETE single record

Note: Requires an access_token. See Auth

DELETE /api/v4/worlds/:id

This example assumes we want to remove the record where id=4:

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "access_token: ACCESS_TOKEN" -H "client: CLIENT" -H "uid: jenny@example.com" -X DELETE https://ed-materializer.herokuapp.com/api/v4/worlds/4

NOTE: Special "application" role users such as EDDiscovery will also need to submit a "user" param on the root level specifying the commander name. This is a required field.