Twinstang API
Welcome to the documentation for the Twinstang api.
Getting Started
The api is like most apis. Currently it only supports basic auth but plans for oauth are in the works. Usage is simple. Use /api/v1/whatevermethod you want. Everything is returned as json.
Methods
help/test
Tests the api is live.
URL
http://twinstang.com/api/v1/help/test
Formats
json, js
HTTP Method
GET
Authentication
none
Usage Notes
Example queries
Curl example
- curl http://twinstang.com/api/v1/help/test
help/test_basic_auth
Tests the api is live and your basic auth is working.
URL
http://twinstang.com/api/v1/help/test_basic_auth
Formats
json, js
HTTP Method
GET
Authentication
basic auth
Usage Notes
Example queries
Curl example
- curl -u username:password http://twinstang.com/api/v1/help/test_basic_auth
users/:login
Get user information about a user by querying by login.
URL
http://twinstang.com/api/v1/users/:login
Formats
json, js
HTTP Method
GET
Authentication
none
Usage Notes
- Pass in the user's login (username) where :login is in the above url.
Example queries
Curl example
- curl http://twinstang.com/api/v1/users/scottmotte
users/:login/total_flights
Get the total flights count a user has entered by querying by login.
URL
http://twinstang.com/api/v1/users/:login/total_flights
Formats
json, js
HTTP Method
GET
Authentication
none
Usage Notes
- Pass in the user's login (username) where :login is in the above url.
Example queries
Curl example
- curl http://twinstang.com/api/v1/users/scottmotte/total_flights
users/:login/flights
Get the recent 20 flights from a user
URL
http://twinstang.com/api/v1/users/:login/flights
Formats
json, js
HTTP Method
GET
Authentication
none
Usage Notes
- Pass in the user's login (username) where :login is in the above url.
Example queries
Curl example
- curl http://twinstang.com/api/v1/users/scottmotte/flights
flights
Get the recent flights from the current user's flight stream
URL
http://twinstang.com/api/v1/flights
Formats
json, js
HTTP Method
GET
Authentication
http auth
Usage Notes
- Pass in the user's login and password in the http authentication.
Example queries
Curl example
- curl http://scottmotte:password@twinstang.com/api/v1/flights
flights POST
create a flight for the current user
URL
http://twinstang.com/api/v1/flights
Formats
json, js
HTTP Method
POST
Authentication
http auth
Usage Notes
- Pass in the user's login and password in the http authentication.
- Pass in the flight data in the header - remark,date,aircraft,ident,departure,arrival,route,hours,dual_hours,solo_hours,pic_hours,cc_hours,day_hours,night_hours,instruct_hours,actual_instrument_hours,simulated_instrument_hours,landings,day_landings,night_landings,instrument_landings,
- date is required
- raises BadRequest 400 HTTP error if formatting of POST data is wrong
Example queries
Curl example
- curl -u scottmotte:password -X POST -d "flight[remark]=This+is+a+curl+sentence&flight[date]=08/23/09" http://twinstang.com/api/v1/flights
users/:login or users/update_settings PUT
Sets and updates values that users are able to set under their settings page.
URL
http://twinstang.com/api/v1/users/:login or http://twinstang.com/api/v1/users/update_settings
Formats
json, js
HTTP Method
PUT
Authentication
http auth
Usage Notes
- Pass in the user's login and password in the http authentication.
- Pass in the user data in the header -
full_name, email, license, home_airport, notice_to_email_me_when_someone_starts_following_me, notice_to_email_me_when_someone_comments_on_one_of_my_flights, show_hours_pic_on_flight_form
- raises BadRequest 400 HTTP error if formatting of PUT data is wrong
Example queries
Curl example
- curl -u scottmotte:password -X POST -d "user[full_name]=Dude&user[show_hours_pic_on_flight_form]=true" http://twinstang.com/api/v1/users/update_settings