Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs for 8 endpoints and fixed 3 of them #468

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion endpoints/address/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source [Iceland Post](https://postur.is)

- GET [/address](https://apis.is/address)
- GET [/address](https://apis.is/address)

Lookup addresses in Iceland through the Icelandic Post API

Expand Down
2 changes: 1 addition & 1 deletion endpoints/aur/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source [ISX.is](https://isx.is)

- GET [/aur](https://apis.is/aur)
- GET [/aur](https://apis.is/aur)

Current Auroracoin exchange rate and various statistics for the past day.

Expand Down
2 changes: 1 addition & 1 deletion endpoints/bus/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source [bus.is](https://bus.is)

- GET [/bus/realtime](https://apis.is/bus/realtime)
- GET [/bus/realtime](https://apis.is/bus/realtime)

Real-time location of busses. Results are only shown for active busses.

Expand Down
17 changes: 17 additions & 0 deletions endpoints/calendar/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Icelandic holidays and other special days

Source: [Node module fridagar](https://www.npmjs.com/package/fridagar)

- GET [/calendar/:year](https://apis.is/calendar/:year)
- GET [/calendar/:year/:month](https://apis.is/calendar/:year/:month)
- GET [/calendar/:year/:month/:day](https://apis.is/calendar/:year/:month/:day)

Returns if a given date range has or is a holiday.

| Parameters | Description | Example |
|------------|-----------------------------------------------|---------------------------------------------------|
| :year | Returns all dates within given year | [2018](https://apis.is/calendar/2018) |
| :month | Returns all dates within given year and month | [2018/12](https://apis.is/calendar/2018/12) |
| :day | Returns all dates within given date | [2018/12/23](https://apis.is/calendar/2018/12/23) |

---
2 changes: 1 addition & 1 deletion endpoints/car/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [The Road Traffic Directorate](http://www.samgongustofa.is/umferd/okutaeki/okutaekjaskra/uppfletting)

- GET [/car](https://apis.is/car)
- GET [/car](https://apis.is/car)

Search the Icelandic vehicle registry.

Expand Down
9 changes: 9 additions & 0 deletions endpoints/carparks/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Status of Icelandic multi storey car parks

Source: [The Parking Permit Treasury](https://www.bilastaedasjodur.is)

- GET [/carparks](https://apis.is/carparks)

Get the current status of the icelandic multi storey car parks.

---
1 change: 1 addition & 0 deletions endpoints/carparks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ app.get('/carparks', (req, res) => {
obj.results.push({
name: $(that).find('aside h2').text(),
address: $(that).find('h5').text(),
openingHours: $(that).find('.hours h1').text(),
parkingSpaces: {
free: !isNaN(freeSpaces) ? freeSpaces : null,
total: !isNaN(totalSpaces) ? totalSpaces : null,
Expand Down
2 changes: 1 addition & 1 deletion endpoints/company/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Search the Icelandic company registry
| Name | Company name | [Blendin](https://apis.is/company?name=blendin) |
| Address | Company's address | |
| SocialNumber | Company's social security number / ID number | |
| VSKNR | Company's VAT-number (VSK in icelandic) || |
| VSKNR | Company's VAT-number (VSK in icelandic) | |

---
7 changes: 3 additions & 4 deletions endpoints/currency/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Source: [m5.is](http://m5.is/), [Arion banki](https://arionbanki.is/) and [Landsbankinn](https://landsbankinn.is/)

- GET [/currency/:source](https://apis.is/currency/:source)
- GET [/currency/:source](https://apis.is/currency/:source)

Get currency data in relation to ISK

| Parameters | Description | Example |
|--------------------|---------------------|-----------------------|
| Parameters | Description | Example |
|--------------------|---------------------|-----------------------------------------------------------------------------------------------------------------|
| :source (required) | Which source to use | [m5](https://apis.is/currency/m5), [arion](https://apis.is/currency/arion) or [lb](https://apis.is/currency/lb) |


---
2 changes: 1 addition & 1 deletion endpoints/cyclecounter/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [Bicycle Counter](http://bicyclecounter.dk/)

- GET [/cyclecounter](https://apis.is/cyclecounter)
- GET [/cyclecounter](https://apis.is/cyclecounter)

Get current status of bicycle counters in Iceland, currently only one located by Suðurlandsbraut in Reykjavík.

Expand Down
11 changes: 11 additions & 0 deletions endpoints/declension/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Declension of Icelandic words

- GET [/declension/:word](https://apis.is/declension/:word)

It takes in a given word and returns the permutations of said word, with its (icelandic: fall, tölu and kyn).

| Parameters | Description | Example |
|------------|------------------------------------------|---------------------------------------------|
| :word | Returns declension result for given word | [hestur](https://apis.is/declension/hestur) |

---
2 changes: 1 addition & 1 deletion endpoints/declension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getDeclensions(callback, providedParams) {
// more than 1 result from request (ex: 'hús')
if (result.length > 1) {
// call recursively again with new url
const id = result[0].attribs.on_click.match(/\d+/)[0]
const id = result[0].attribs.onclick.match(/\d+/)[0]
baseUrl.query = { id }
params.url = url.format(baseUrl)
return getDeclensions(callback, params)
Expand Down
2 changes: 1 addition & 1 deletion endpoints/earthquake/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [Icelandic Meteorological Office](http://vedur.is)

- GET [/earthquake/is](https://apis.is/earthquake/is)
- GET [/earthquake/is](https://apis.is/earthquake/is)

Get earthquake monitoring data for the last 48 hours.

Expand Down
2 changes: 1 addition & 1 deletion endpoints/flight/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [Keflavik Airport](https://kefairport.is/)

- GET [/flight](https://apis.is/flight)
- GET [/flight](https://apis.is/flight)

Get a list of all international flights departing and arriving at Keflavik Airport today.

Expand Down
15 changes: 15 additions & 0 deletions endpoints/golf/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Icelandic golf courses and course time

Source: [Golf in Iceland](https://mitt.golf.is/pages/rastimar/)

- GET [/golf/clubs](https://apis.is/golf/clubs)

Get list of all golf courses in Iceland.

- GET [/golf/teetimes](https://apis.is/golf/teetimes)

| Parameters | Description | Example |
|-----------------|-------------------------------------------|-------------------------------------------------------------------------|
| Club (required) | ID number of a golf club from /golf/clubs | [100](https://apis.is/golf/teetimes?club=100) (Golfklúbbur Reykjavíkur) |

---
4 changes: 2 additions & 2 deletions endpoints/golf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ app.get('/golf/teetimes', (req, res) => {
// http://stackoverflow.com/a/20091919
rejectUnauthorized: false,
headers: { 'User-Agent': h.browser() },
url: `http://mitt.golf.is/pages/rastimar/rastimayfirlit/?club=${clubId}`,
url: `https://mitt.golf.is/pages/rastimar/rastimayfirlit/?club=${clubId}`,
}, (err, response, html) => {
if (err || response.statusCode !== 200) {
return res.status(500).json({
Expand Down Expand Up @@ -48,7 +48,7 @@ app.get('/golf/clubs', (req, res) => {
// http://stackoverflow.com/a/20091919
rejectUnauthorized: false,
headers: { 'User-Agent': h.browser() },
url: 'http://mitt.golf.is/pages/rastimar/',
url: 'https://mitt.golf.is/pages/rastimar/',
}, (err, response, html) => {
if (err || response.statusCode !== 200) {
return res.status(500).json({
Expand Down
2 changes: 1 addition & 1 deletion endpoints/horses/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [Worldfengur.com](http://www.worldfengur.com/freezone_horse.jsp?c=EN)

- GET [/horses](https://apis.is/horses)
- GET [/horses](https://apis.is/horses)

Search the Icelandic horse database Worldfengur.
**NB: At least one of the following is required, id, name and origin or microchip.**
Expand Down
2 changes: 1 addition & 1 deletion endpoints/hospital/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [The National University Hospital of Iceland](http://landspitali.is)

- GET [/hospital](https://apis.is/hospital)
- GET [/hospital](https://apis.is/hospital)

Get the current status of the National University Hospital of Iceland.

Expand Down
9 changes: 9 additions & 0 deletions endpoints/isbolti/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Icelandic football league

Source: [Fótbolti.net](https://fotbolti.net/isboltinn.php)

- GET [/isbolti](https://apis.is/isbolti)

Get the current status of the icelandic football clubs.

---
13 changes: 13 additions & 0 deletions endpoints/isnic/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# .is domain registry info

Source: [ISNIC: .is Domain name registration](https://www.isnic.is/en/whois/)

- GET [/isnic](https://apis.is/isnic)

Search the Icelandic domain registry.

| Parameters | Description | Example |
|--------------------|------------------------|-------------------------------------------------------|
| Domain (required) | Registered domain name | [advania.is](https://apis.is/isnic?domain=advania.is) |

---
2 changes: 1 addition & 1 deletion endpoints/lottery/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [The Icelandic Government Lottery](https://games.lotto.is/)

- GET [/lottery](https://apis.is/lottery)
- GET [/lottery](https://apis.is/lottery)

Get the most recent numbers for the Icelandic lottery.

Expand Down
21 changes: 21 additions & 0 deletions endpoints/names/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Icelandic names

Source: [Icelandic National Registry](https://www.island.is/mannanofn/leit-ad-nafni/)

- GET [/names/:category](https://apis.is/names/:category)

Lists all approved Icelandic names. A search parameter can be used with each endpoint.

| Parameters | Description | Example |
|------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| :category | Which category to search for | [males](https://apis.is/names/males), [females](https://apis.is/names/females) or [middle names](https://apis.is/names/middlenames) |

- GET [/names/rejected/:category](https://apis.is/names/rejected/:category)

Lists all rejected Icelandic names. A search parameter can be used with each endpoint.

| Parameters | Description | Example |
|------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| :category | Which category to search for | [males](https://apis.is/names/rejected/males), [females](https://apis.is/names/rejected/females) or [middle names](https://apis.is/names/rejected/middlenames) |

---
55 changes: 24 additions & 31 deletions endpoints/names/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const app = require('../../server')
/* Handles the request for a specific request URL */
function handleRequest(providedUrl, req, res) {
let $
// Check for the filter parameter
const filter = req.params.filter || req.query.filter || req.query.search || ''
// Check for the search parameter
const search = req.params.search || req.query.search || req.query.filter || ''

// Add name filtering if it is requested
// Add search if it is requested
let url = providedUrl || ''
if (filter !== '') {
url += `&Nafn=${filter}`
if (search !== '') {
url += `&Nafn=${search}`
}

request.get({
Expand All @@ -41,14 +41,12 @@ function handleRequest(providedUrl, req, res) {
const obj = { results: [] }

// Clear data regarding the acceptance date of the name (not needed)
$('.dir li i').each(() => {
$(this).remove()
})
$('.dir li i').remove()

// Loop through all the names in the list and add them to our array
$('.dir li').each(() => {
const name = $(this).text()
obj.results.push(name.trim())
$('.dir li').each((i, el) => {
const name = $(el).text().trim()
obj.results.push(name)
})

// Return the results as JSON and cache for 24 hours
Expand All @@ -58,59 +56,54 @@ function handleRequest(providedUrl, req, res) {

/* Root names handler - only returns a list of resources */
app.get('/names', (req, res) => {
return res.json({
results: [
{
// eslint-disable-next-line max-len
info: 'This is an api that lists all allowed Icelandic names. A search parameter can be used with each endpoint',
endpoints: {
males: '/names/males/',
females: '/names/females/',
middlenames: '/names/middlenames/',
},
},
],
})
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Samthykkt=yes'
return handleRequest(url, req, res)
})

/* Get all legal names for males */
app.get('/names/males/:filter?', (req, res) => {
app.get('/names/males/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Drengir=on&Samthykkt=yes'
return handleRequest(url, req, res)
})

/* Get all legal names for females */
app.get('/names/females/:filter?', (req, res) => {
app.get('/names/females/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Stulkur=on&Samthykkt=yes'
return handleRequest(url, req, res)
})

/* Get all legal middle names */
app.get('/names/middlenames/:filter?', (req, res) => {
app.get('/names/middlenames/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Millinofn=on&Samthykkt=yes'
return handleRequest(url, req, res)
})

/* Get all rejected names for males */
app.get('/names/rejected/males/:filter?', (req, res) => {
app.get('/names/rejected/males/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Drengir=on&Samthykkt=no'
return handleRequest(url, req, res)
})

/* Get all rejected names for females */
app.get('/names/rejected/females/:filter?', (req, res) => {
app.get('/names/rejected/females/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Stulkur=on&Samthykkt=no'
return handleRequest(url, req, res)
})

/* Get all rejected middle names */
app.get('/names/rejected/middlenames/:filter?', (req, res) => {
app.get('/names/rejected/middlenames/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Millinofn=on&Samthykkt=no'
return handleRequest(url, req, res)
})

/* Get all rejected names */
app.get('/names/rejected/:filter?', (req, res) => {
app.get('/names/rejected/:search?', (req, res) => {
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Stulkur=on&Drengir=on&Millinofn=on&Samthykkt=no'
return handleRequest(url, req, res)
})

/* Get all names with a given search */
app.get('/names/:search', (req, res) => {
sse87 marked this conversation as resolved.
Show resolved Hide resolved
const url = 'https://www.island.is/mannanofn/leit-ad-nafni/?Stafrof=&Samthykkt=yes'
return handleRequest(url, req, res)
})
2 changes: 1 addition & 1 deletion endpoints/particulates/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [Reykjavik City](http://reykjavik.is/)

- GET [/particulates](https://apis.is/particulates)
- GET [/particulates](https://apis.is/particulates)

Get current status of particulates in Reykjavik City

Expand Down
2 changes: 1 addition & 1 deletion endpoints/petrol/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Source: [github.com/gasvaktin](https://github.com/gasvaktin/gasvaktin)

- GET [/petrol](https://apis.is/petrol)
- GET [/petrol](https://apis.is/petrol)

Lookup locations and gas prices for petrol stations in Iceland.

Expand Down
4 changes: 2 additions & 2 deletions endpoints/ship/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Source: [The Icelandic Transport Authority](https://www.samgongustofa.is/sigling

Search the Icelandic ship registry

| Parameters | Description | Example |
|-------------------|---------------------------------------------------------------|---------------|
| Parameters | Description | Example |
|-------------------|---------------------------------------------------------------|------------------------------------------------------------------------------------------|
| Search (required) | Ship name, regional code or the registy's registration number | [engey](https://apis.is/ship?search=engey), [RE-100](https://apis.is/ship?search=RE-100) |

---
Loading