Coder Social home page Coder Social logo

ubike-rest's Introduction

ubike-rest

a HTTP API to find 2 nearest ubike station based on latitude and longitude in request parameters.

/v1/ubike-station/taipei

  • Request Method: GET
  • Request Parameters:
    • lat: latitude of location
    • lng: longitude of location
  • Spec and Error Handling:
    • for any location not in Taipie City, please return error code -2.
    • please handle error/exceptions with following scenarios (and return coressponding error codes)
      • 1: all ubike stations are full
      • 0: OK
      • -1: invalid latitude or longitude
      • -2: given location not in Taipei City
      • -3: system error
    • please return empty list as result while returning non-zero code.
    • please return station with non-zero ubikes (i.e., skip station without ubikes).

Response

  • Content Type: application/json
  • Body
{
    "code": $error-code,
    "result": [
        {
           "station": "$name-of-station", 
           "num_ubike": $number-of-available-ubike
        },
        {
           "station": "$name-of-station", 
           "num_ubike": $number-of-available-ubike
        }
    ]
}

Sample Requests

# sample 1
# request
GET /v1/ubike-station/taipei?lat=25.034153&lng=121.568509

# response
Content-Type: application/json

    {
        "code": 0,
        "result": [
            {"station": "捷運象山站", "num_ubike": 10},
            {"station": "世貿二館", "num_ubike": 33}
        ]               
    }

# sample 2
# request
GET /v1/ubike-station/taipei?lat=24.999087&lng=121.327547

# response
Content-Type: application/json

    {
        "code": -2,
        "result": []
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.