GithubHelp home page GithubHelp logo

backend_test's Introduction

Local Search API

This API allows searching for locations within a given radius of a longitude and latitude.

The SQL query for task 1 is provided in task1.txt

Video walkthrough

Endpoints

GET

Allows searching for locations within a circular or square area.

Query Parameters

  • long: The longitude of the search origin.
  • lat: The latitude of the search origin.
  • distance: The radius in meters of the search area.
  • circle: Set to true for a circular search area, (default) false for square bounding box around coordinates.

Example Requests

  • Search within 100m of (-88.33, 36.33): /search?long=-88.33&lat=36.33&distance=100
  • Circular search within 200m: /search?long=-88.33&lat=36.33&distance=200&circle=true

Response

Returns a JSON array of location objects, ordered by distance from the search origin (closest first), then by rating (highest first) for locations within 50m of the query coordinates.

A location object contains:

  • id
  • name
  • website
  • coordinates
  • description
  • rating
  • distance (in meters)

Error Responses

400 Bad Request if invalid query parameters are passed. 500 Internal Server Error for any server-side issues.

Local Setup

To run locally:

  • Install Go.
  • Clone this repo.
  • Install dependencies: go get ./...
  • The main data management logic is handled in data.go. The database path can be changed in get.go. The main.go file initializes the API, starts the server and provides error handling.
  • Start the server: go run main.go.
  • The API will be running on http://localhost:8000.

backend_test's People

Contributors

baberabb avatar

Watchers

 avatar

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.