Bart Notifier Service

An API to query up-to-date arrival times and schedule arrival notifications

Usage: bns <command> [options]

command     
  seed-db             clear and reinitialize the database
  clear-db            clear the database
  start-server        start the api server
  gen-static-docs     generate docs for the api

Options:
   -v VERBOSITY, --verbosity VERBOSITY   verbosity level (trace | debug | info | warn | error | fatal)

Environment variables: 
  BART_NOTIFIER_DB_URI - the database uri
  BART_NOTIFIER_BART_API_KEY - your BART API key
  BART_NOTIFIER_TWILIO_API_KEY - your twilio API key
  BART_NOTIFIER_TWILIO_SID - your twilio SID
  BART_NOTIFIER_TWILIO_NUMBER - your twilio number



/stations []

get station information

GET -- /stations []

Find objects in this Collection.

Parameters


name description required location default schema
query Query spec (JSON) no query null
{
  "type": "object"
}
view View no query null
{
  "type": "string"
}
sort Sort spec (JSON) no query null
{
  "type": "object"
}
projection Projection spec (JSON) no query null
{
  "type": "object"
}
skip Results to skip no query null
{
  "type": "integer"
}
limit Results to limit no query null
{
  "type": "integer"
}

Responses


status code description headers schema
200 Returns an array of objects. Each object has an _id and possible additional properties.
null
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "_id": {
        "type": "string"
      }
    },
    "required": [
      "_id"
    ]
  }
}
400 Request is malformed (i.e. invalid parameters).
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}
403 User is not authorized to run this operation.
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}
500 There was an unexpected internal error processing this request.
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}

/stations/:_id []

GET -- /stations/:_id []

Find an object in this Collection by _id.

Parameters


name description required location default schema
_id Object _id yes path null null
view View no query null
{
  "type": "string"
}

Responses


status code description headers schema
200 Returns the object resource found at this URL specified by id.
null
{
  "type": "object",
  "properties": {
    "_id": {
      "type": "string"
    }
  },
  "required": [
    "_id"
  ]
}
400 Request is malformed (i.e. invalid parameters).
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}
403 User is not authorized to run this operation.
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}
404 Collection resource cannot be found by the supplied _id.
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}
500 There was an unexpected internal error processing this request.
null
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "description": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "code",
    "description",
    "message"
  ]
}

/stations/:_id/:id/destinations []

Per station destinations.

GET -- /stations/:_id/:id/destinations []

Retrieve a list of valid destinations for a particular station.

Parameters


name description required location default schema
_id Object _id yes path null null
id id yes path null null

/stations/:_id/:id/arrivals []

Per station estimated arrival times.

GET -- /stations/:_id/:id/arrivals []

Retrieve a list of estimated arrival times for a particular station

Parameters


name description required location default schema
_id Object _id yes path null null
id id yes path null null
destination Filter results by destination (e.g., "RICH" for all Richmond bound trains) no query null
{
  "type": "string",
  "pattern": "^[a-zA-Z0-9]{4}$"
}

/notifications []

Arrival notifications.

GET -- /notifications []

List active arrival notifications.

Parameters


name description required location default schema
destination Filter results by destination. no query null
{
  "type": "string",
  "pattern": "^[a-zA-Z0-9]{4}$"
}
skip Skip the first N results. no query 0
{
  "type": "integer",
  "minimum": 0
}
limit Limit the number of results returned. no query 10
{
  "type": "integer",
  "minimum": 1
}

POST -- /notifications []

Create a new notification.

Parameters


name description required location default schema
body Notification object yes body null
{
  "type": "object",
  "properties": {
    "station": {
      "type": "string"
    },
    "destination": {
      "type": "string"
    },
    "datetime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer",
          "minimum": 0
        }
      ]
    },
    "delta": {
      "type": "integer",
      "minimum": 10,
      "maximum": 30
    }
  },
  "required": [
    "station",
    "destination",
    "datetime",
    "delta"
  ],
  "additionalProperties": false
}

DELETE -- /notifications []

Cancel all active notifications.

/notifications/:id []

Arrival notification details.

GET -- /notifications/:id []

Retrieve a specific notification.

Parameters


name description required location default schema
id id yes path null null
destination Filter by destination ID. no query null
{
  "type": "string",
  "pattern": "^[a-zA-Z0-9]{4}$"
}

PATCH -- /notifications/:id []

Update a notification.

Parameters


name description required location default schema
id id yes path null null
body Notification object. yes body null
{
  "type": "object",
  "properties": {
    "station": {
      "type": "string"
    },
    "destination": {
      "type": "string"
    },
    "datetime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer",
          "minimum": 0
        }
      ]
    },
    "delta": {
      "type": "integer",
      "minimum": 10,
      "maximum": 30
    }
  },
  "minProperties": 1,
  "additionalProperties": false
}
bart-key test header no header null
{
  "type": "string"
}

DELETE -- /notifications/:id []

Cancel a specific notification.

Parameters


name description required location default schema
id id yes path null null