Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ltfschoen/opendata-test
Ruby app to experiment with Transport for NSW (TfNSW) Open Data API datasets
https://github.com/ltfschoen/opendata-test
curl dotenv https net-http nsw-government opendata-api ruby transport
Last synced: about 1 month ago
JSON representation
Ruby app to experiment with Transport for NSW (TfNSW) Open Data API datasets
- Host: GitHub
- URL: https://github.com/ltfschoen/opendata-test
- Owner: ltfschoen
- License: mit
- Created: 2017-12-21T08:05:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-22T04:55:08.000Z (about 7 years ago)
- Last Synced: 2024-10-19T16:01:15.669Z (3 months ago)
- Topics: curl, dotenv, https, net-http, nsw-government, opendata-api, ruby, transport
- Language: Ruby
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenData API
* About:
* Ruby application with HTTP(S) Session to re-use across multiple requests that are configured to use [Transport for NSW Open Data APIs](https://opendata.transport.nsw.gov.au). Currently configured to use:
* Traffic Volume Counts API
* Trip Planner API* Quick Start
* Obtain and Setup API Keys from OpenData API
* Register with OpenData API
* Create App
* Select API
* Obtain associated API Keys
* Add API Keys to .env file (i.e. `OPENDATA_API_KEY=`)
* Add or Update a module in ./config/config.rb with the API configuration
* Import the API configuration module into implementation code (i.e. ./src/main.rb)
* Install dependencies
```
bundle install
```
* Run
```
bundle exec ruby ./src/main.rb
```* Setup Log
* User Guide for OpenData API - https://opendata.transport.nsw.gov.au/user-guide
* Register - https://opendata.transport.nsw.gov.au/user/register
* Verify Password
* Login* Create App
* https://opendata.transport.nsw.gov.au/user/6773
* Go to My Account > Applications
* Click "Add Application"
* Application Name - "congestion"
* Link - https://opendata.transport.nsw.gov.au/application/congestion
* Select API - "Traffic Volume Counts API", "Trip Planner API"
* API Key - Add to .env file* Use API
* Browse Data
* Select an API
* Choose how to use API
* Click either "Explore API" (opens API Explorer), then set Authentication type as "API Key", then click "Expand Operations" to see resource details, method, parameters, and response messages for a query
* Click "Download" (static datasets)
* Developers > API Exporer - https://opendata.transport.nsw.gov.au/node/2171/exploreapi#!/default/get_spatial
* Click the button "Try it out!"* Create Application
* Create Ruby file ./src/main.rb
* Create .env file
* Setup Gemfile
* Go to http://bundler.io/
* Run `gem install bundler`
* Add demo contents to Gemfile
* Add DotEnv Gem - https://github.com/bkeepers/dotenv
* Use Net HTTP to create request to OpenData API to replicate the following cURL request
```
curl -X GET --header 'Accept: application/json' --header 'Authorization: apikey ' 'https://api.transport.nsw.gov.au/v1/roads/spatial?format=geojson&q=select%20*%20from%20road_traffic_counts_station_reference%20limit%2050%20'
```
* Run with `bundle exec ruby ./src/main.rb`