code-schools-api-golang

command module
v0.0.0-...-9aaae71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2020 License: CC0-1.0 Imports: 11 Imported by: 0

README

Code.org Schools Geolocation API

Code.org provides a robust database of computer science courses and schools ranging from beginner all the way through to university courses. This Go App takes the data from their endpoint and allows you to search for the nearest courses to the location provided. This App is designed to be deployed onto Heroku using the Go Buildpack.

This API was created to work with the Code.org Local School Search Lightning Web Component.

The Lightning Web Component demonstrates a method for bringing external data into a Lightning Web Component. This component utilizes the code.org computer science school & program database to display the nearest three schools to a given property.

Check out the Code.org Schools API.

Running Locally

Make sure you have Go version 1.12 or newer and the Heroku Toolbelt installed.

$ git clone https://github.com/schandlergarcia/code-schools-api-golang
$ cd go-getting-started
$ go build -o bin/code-schools-api-golang -v . # or `go build -o bin/go-getting-started.exe -v .` in git bash
golang.org/x/net/context
github.com/heroku/x/hmetrics
github.com/heroku/x/hmetrics/onload
github.com/heroku/go-getting-started
$ heroku local

Your app should now be running on localhost:5000.

Deploying to Heroku

$ heroku create
$ git push heroku master
$ heroku open

or

Deploy

Using the API

  • URL

    https://app-name.herokuapp.com/

  • Method:

    GET

  • URL Params

    Required:

    lat=[decimal]

    lon=[decimal]

  • Success Response:

    • Code: 200
      Content: [{"name":"Saint Georges School","website":"https://www.google.com/search?q=saint+georges+school+middletown","levels":["High School"],"format":"In School","format_description":"AP Computer Science","gender":"Both","description":"Advanced Placement Computer Science course - 5 days a week high school course to prepare for the College Board advanced placement exam. Teaches the Java language","languages":["Java"],"money_needed":false,"online_only":false,"number_of_students":null,"contact_name":"","contact_number":"","contact_email":"","latitude":41.491,"longitude":-71.2734,"street":"Purgatory Road","city":"Middletown","state":"RI","zip":"02842","published":1,"updated_at":"2013-11-16T18:25:57Z","country":"United States","source":"apcs","Distance":12.484052821222221},{"name":"Dartmouth High School","website":"http://dartmouthps.dhs.schoolfusion.us/","levels":["High School"],"format":"In School","format_description":"Other","gender":"Both","description":"AP Computer Science\r\nWeb Page Design\r\nIntroduction to Programming and Gaming using Visual Basic\r\nOther courses will also be participating in the Hour of Code event such as Freshman Seminar.\r\n","languages":["HTML","Java","Visual basic"],"money_needed":false,"online_only":false,"number_of_students":null,"contact_name":"","contact_number":"","contact_email":"","latitude":41.5916,"longitude":-70.9801,"street":"555 Bakerville Road","city":"Dartmouth","state":"MA","zip":"02748","published":1,"updated_at":"2013-12-08T02:11:21Z","country":"United States","source":"user","Distance":17.387791680818605},{"name":"Dartmouth High School","website":"https://www.google.com/search?q=dartmouth+high+school+dartmouth","levels":["High School"],"format":"In School","format_description":"AP Computer Science","gender":"Both","description":"Advanced Placement Computer Science course - 5 days a week high school course to prepare for the College Board advanced placement exam. Teaches the Java language","languages":["Java"],"money_needed":false,"online_only":false,"number_of_students":null,"contact_name":"","contact_number":"","contact_email":"","latitude":41.5916,"longitude":-70.9801,"street":"Bakerville Road","city":"Dartmouth","state":"MA","zip":"02748","published":1,"updated_at":"2013-11-16T18:25:45Z","country":"United States","source":"apcs","Distance":17.387791680818605}]
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error : "Location not found" }
  • Sample Call from Apex:

  @AuraEnabled(cacheable=true)
  public static String getNearbyCodeSchools(Decimal propertyLatitude, Decimal propertyLongitude) {
    // Construct our Callout URL with our Lat and Lon from the component
    String calloutURL = 'https://enigmatic-gorge-00974.herokuapp.com/?lat=' + propertyLatitude + '&lon=' + propertyLongitude;
    String response = calloutToGoServer(calloutUrl);
    return response;
  }

Go on Heroku

For more information about using Go on Heroku, see these Dev Center articles:

Built With

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL