Skip to content

plexus/yakports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yakports

A demonstration of how to use Yaks to build a hypermedia API. It also contains some helpful snippets that might make it into Yaks proper, such as how to set up integration with Grape, or how to handle pagination in a CollectionMapper.

You can browse the API using the HAL browser

or try it on the command line with curl.

Some example URLs

http://yaks-airports.herokuapp.com/countries/DE
http://yaks-airports.herokuapp.com/airports/TXL
http://yaks-airports.herokuapp.com/countries/DE/airports
http://yaks-airports.herokuapp.com/countries/DE/airlines

Use the Accept header to request different formats.

The data is taken from OpenFlights

HAL

$ curl -H 'Accept: application/hal+json' http://yaks-airports.herokuapp.com/countries/DE
{
  "id": "DE",
  "name": "Germany",
  "iso3166_1_alpha_2": "DE",
  "dst_type": "E",
  "_links": {
    "airports": {
      "href": "/countries/DE/airports"
    },
    "airlines": {
      "href": "/countries/DE/airlines"
    }
  }

Collection+JSON

$ curl -H 'Accept: application/vnd.collection+json' http://yaks-airports.herokuapp.com/countries/DE
{
  "collection": {
    "version": "1.0",
    "items": [
      {
        "data": [
          {
            "name": "id",
            "value": "DE"
          },
          {
            "name": "name",
            "value": "Germany"
          },
          {
            "name": "iso3166_1_alpha_2",
            "value": "DE"
          },
          {
            "name": "dst_type",
            "value": "E"
          }
        ],
        "links": [
          {
            "rel": "airports",
            "href": "/countries/DE/airports"
          },
          {
            "rel": "airlines",
            "href": "/countries/DE/airlines"
          }
        ]
      }
    ]
  }
}

JSON-API

$ curl -H 'Accept: application/vnd.api+json' http://yaks-airports.herokuapp.com/countries/DE
{
  "countries": [
    {
      "id": "DE",
      "name": "Germany",
      "iso3166_1_alpha_2": "DE",
      "dst_type": "E"
    }
  ],
  "linked": {
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published