API

Fredagskakan erbjuder ett API för att kollegor bland annat ska kunna hålla koll på veckans kaka. Det finns även möjlighet att sortera och titta på historiska betyg.
Det nya API:et introducerar även möjlighet att rösta*

API URL: https://vote.fredagskakan.se

*) Röstning kan enbart göras med hjälp av API-nyckel som måste utfärdas av Fredagskakan.se

Get kaka for current week

GET /thisweek

Output:

{
  "Kaka": "Fastlagsbulle",
  "URL": "https://s3-eu-west-1.amazonaws.com/fredagskakan/semla.jpeg"
}
HTTP response code Status
200 OK
500 Something went wrong

Get a list of kakor

GET /getkaka/:year/:week

Parameters:

year (optional): four-digit representation of a year, i.e. 2019

week (optional): two-digit representation of a week number, i.e. 10

Output:

If both year and week parameters are present, an object as described below is returned by itself. If year or no parameters are present, an array of objects as described below is returned.

Object:

{
   "Kaka": "Fastlagsbulle",
   "Scores": [
      {
         "Location": "S4",
         "Score": 3.076923076923077
      },
      {
         "Location": "T6",
         "Score": 4
      },
      {
         "Location": "all",
         "Score": "3.53846153846"
      }
   ]
}
HTTP response code Status
200 OK
404 No kakor found
500 Something went wrong

 

Cast a vote

POST /vote

Input:

{
   "timestamp":
   "location":
   "score":
   "api_key":
}

Output:

{
   "Status":   "OK"
}
HTTP response code Status
200 Vote was registered
400 Invalid data in POST
403 Vote was cast outside of voting window or API key is incorrect
500 Something went wrong

Get current average score for ongoing vote

GET /currentscore/:location

Parameters:

location (optional): A location, i.e. “T6”. If ommited, the current average score for all locations will be returned.

Output:

{
   "Location": "all"
   "Score":    "3.1415"
}
HTTP response code Status
200 OK
500 Something went wrong

List all locations

GET /listlocations

Output:

{
  "Locations":
  [
    "T6",
    "S4"
  ]
}
HTTP response code Status
200 OK
500 Something went wrong