From AdWords to Firebase: The Road to API Nirvana

From AdWords to Firebase: The Road to API Nirvana

Transcript

  1. From AdWords to Firebase The Road to API Nirvana Mandy

    Waite Developer Advocate at Google @tekgrrl
  2. @tekgrrl Everything at Google is or has an API

  3. @tekgrrl

  4. @tekgrrl The utility of an API is not always dependent

    on it’s implementation
  5. @tekgrrl AdWords API Learnings • Errors can cost you money

    • Always be prepared to retry a failed call • A reasonable number of retries is fine • Avoid tight loops, use Exponential backoff • Log hard errors, monitor your severe errors When working with an API, Error handling should never be an afterthought
  6. @tekgrrl Auto generated AdWords API Client Libraries WSDL

  7. @tekgrrl Google APIs

  8. @tekgrrl

  9. @tekgrrl Auto generated Google API Client Libraries Discovery Doc

  10. @tekgrrl Google API Client Libraries Hard to auto-generate in a

    way that is idiomatic to the target language Different languages require different semantics in an API client Many languages have their own particular ways of solving problems A ‘simple’ transaction import googledatastore as datastore req = datastore.BeginTransactionRequest() key = datastore.Key() path = key.path_element.add() path.kind = 'Person' path.name = 'jim' resp = datastore.begin_transaction(req) tx = resp.transaction req = datastore.CommitRequest() req.transaction = tx entity = req.mutation.insert.add() entity.key.CopyFrom(key) prop = entity.property.add() prop.name = 'hometown' prop.value.string_value = 'New York' prop = entity.property.add() prop.name = age prop.value.integer_value = 40 datastore.commit(req)
  11. @tekgrrl

  12. @tekgrrl gcloud client libraries Idiomatic rather than mapped Distributed through

    language-standard tools Community-owned code, issues, and docs gcloud client Authentication Auto-generated Developers
  13. @tekgrrl Transactions the Pythonic way from gcloud import datastore dataset

    = datastore.get_dataset(...) key = Key.from_path(['Person', 'jim']) entity = dataset.get_entity(key) with dataset.transaction(): entity[‘hometown’] = ‘New York’ entity[‘age’] = 40 entity.save() import googledatastore as datastore req = datastore.BeginTransactionRequest() key = datastore.Key() path = key.path_element.add() path.kind = 'Person' path.name = 'jim' resp = datastore.begin_transaction(req) tx = resp.transaction req = datastore.CommitRequest() req.transaction = tx entity = req.mutation.insert.add() entity.key.CopyFrom(key) prop = entity.property.add() prop.name = 'hometown' prop.value.string_value = 'New York' prop = entity.property.add() prop.name = age prop.value.integer_value = 40 datastore.commit(req)
  14. @tekgrrl Mobile Realtime Clients add complexity Complex Transport Unreliable Networks

    Multi Platform
  15. @tekgrrl • NoSQL, JSON database • Pushes updates in milliseconds

    when things change • Security model allows direct access from client devices • Maps each piece of data to a URL The Firebase Realtime Database Firebase can help
  16. @tekgrrl Smart Client The Rise of the Smart Client http://blog.codinghorror.com/the-tablet-turning-point/

    Firebase can help
  17. @tekgrrl Firebase Sync Smart Client Syncs both ways Firebase can

    help
  18. @tekgrrl Smart Clients Sync Firebase Collaboration Firebase can help

  19. @tekgrrl and it’s simple to code to Subtitle JavaScript var

    ref = new Firebase("https://<YOUR-FIREBASE>.firebaseio.com/welcome"); ref.set("Hello Berlin!"); ref.on(“value”, function(value) { var data = value.val(); console.log(data); // prints “Hello Berlin” and listens for // updates });
  20. @tekgrrl Demo

  21. @tekgrrl firebase.com/tutorial

  22. @tekgrrl Start building 1 2 3 Go to cloud.google.com/free-trial $300

    in Cloud Platform credits to launch your idea! Build. Store. Analyze. On the same infrastructure that powers Google Sign up for the free trial Free Trial
  23. @tekgrrl Speedhack tomorrow (with a Firebase challenge)

  24. cloud.google.com Images by Connie Zhou