SlideShare a Scribd company logo
AN IPHONE-PYTHON
                              LOVE AFFAIR
                             Building APIs for Mobile




Wednesday, June 8, 2011
Music Hack Day, February 2011




                                Samantha & Matt


Wednesday, June 8, 2011
ACCOMPLICE #1
                     Anna Callahan: iOS developer, jazz trumpet player
                                         @jazztpt
Wednesday, June 8, 2011
ACCOMPLICE #2
             Nate Aune: Django/Python/Plone developer, saxophonist
                                   @natea
Wednesday, June 8, 2011
VALENTUN.ES!




Wednesday, June 8, 2011
Wednesday, June 8, 2011
MOBILE TAKEOVER
                If you’re not building for mobile now, you will be soon.

Wednesday, June 8, 2011
WHAT’S DIFFERENT ABOUT
                   MOBILE?


    • Isn’t        REST appropriate for everything?

    • Don’t               I want a single API for all clients?




Wednesday, June 8, 2011
WHAT’S DIFFERENT ABOUT
                   MOBILE?
                          Mobile users are unwilling to wait.

       1. Connection = slow, spotty, or
         non-existent




       2. Mobile is not as powerful at
         fetching & saving data or calculations


Wednesday, June 8, 2011
SO YOUR API SHOULD

    • Return              hierarchies of related data

    • Authentication              and Authorization

    • Have            mobile-specific error codes & messages

    • Accept              arrays of related or unrelated data

    • Return              pre-calculated data or data that doesn’t exist on device


Wednesday, June 8, 2011
HIERARCHIES OF DATA

                          Bad :(        Good!

             Cards             Tracks




Wednesday, June 8, 2011
CARD CLASS




Wednesday, June 8, 2011
TRACK CLASS




Wednesday, June 8, 2011
SIMPLE REST API




                          Basic CRUD operations via API.
Wednesday, June 8, 2011
URLS.PY




   Now access cards and tracks with /api/card/ and /api/track/
Wednesday, June 8, 2011
CREATE A CARD




Wednesday, June 8, 2011
WHAT ABOUT TRACKS?




          Default post_list from resources.py (create object via POST)
Wednesday, June 8, 2011
WHAT ABOUT TRACKS?




                          api.py post_list (override method)

Wednesday, June 8, 2011
MOBILE WANTS
                          HIERARCHICAL DATA




Wednesday, June 8, 2011
TASTYPIE MAKES IT EASY




Wednesday, June 8, 2011
AUTHENTICATION &
                           AUTHORIZATION




                          Authentication - let the user in the door
                           Authorization - what the user can see
Wednesday, June 8, 2011
LIMITING BY USER




            Returns only the objects owned by the current user.


Wednesday, June 8, 2011
ERROR CODES

       Ideally your API should:

        •Never return HTML
        •Tailor response codes to actions on device
        •Return messages designed for the end user
        •Never, ever return HTML

Wednesday, June 8, 2011
JSON ERROR RESPONSES




                     override wrap_view from resources.py
Wednesday, June 8, 2011
JSON ERROR HANDLING




                          Objective-C in Xcode

Wednesday, June 8, 2011
Wednesday, June 8, 2011
ACCEPT ARRAYS OF DATA


    • User           enters tunnel

    • User           uses your app

    • User           closes your app

    • User           exits tunnel



Wednesday, June 8, 2011
PRE-CALCULATED DATA OR
           DATA NOT STORED ON
                 DEVICE

    • No   other users are stored
       on device

    • Leaderboards    or other
       calculated user data must
       come from the server



Wednesday, June 8, 2011
THANK YOU!

    • Music   Hack Day Accomplices: Matt Katz, Alexandre Passant,
       Jeff Novich, Twom Deryckere

    • Danielzilla         (Daniel Lindsley) - TastyPie

    • IsaacKelly

    • DjangoCon



Wednesday, June 8, 2011
MORE INFO

    • Valentun.es   live site
       http://valentun.es

    • Valentunes    (Django code)
       https://github.com/natea/valentunes

    • Valentunes    (iPhone code)
       https://github.com/jazztpt/Valentunes_iPhone

    • Valentunes    (Twilio integration)
       https://github.com/terraces/valentunes-twilio

Wednesday, June 8, 2011
DJANGO API FRAMEWORKS

    • TastyPie   documentation (the one we used)
       http://readthedocs.org/docs/django-tastypie/en/latest/

    • django-piston
       https://bitbucket.org/jespern/django-piston/

    • Django    REST framework
       http://django-rest-framework.org


Wednesday, June 8, 2011

More Related Content

Similar to iPhone Python love affair

Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
Sylvain Zimmer
 
2011 The Year of Web apps
2011 The Year of Web apps2011 The Year of Web apps
2011 The Year of Web apps
JungHyuk Kwon
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
Tim Wright
 
Choosing the right Content Management System
Choosing the right Content Management SystemChoosing the right Content Management System
Choosing the right Content Management System
Rachel Andrew
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
ikailan
 
Sinsai.info と Crisis Mapping
Sinsai.info と Crisis Mapping Sinsai.info と Crisis Mapping
Sinsai.info と Crisis Mapping Hal Seki
 
Scaling atlassian os v4
Scaling atlassian os v4Scaling atlassian os v4
Scaling atlassian os v4
Soren Harner
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsMuhammad Ikram Ul Haq
 
Koss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsKoss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsEvil Martians
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaDNAD
 
Mobility in the financial industry
Mobility in the financial industryMobility in the financial industry
Mobility in the financial industry
Vincent Everts
 
iPhone App from concept to product
iPhone App from concept to productiPhone App from concept to product
iPhone App from concept to product
joeysim
 
Atlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide DeckAtlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide Deck
Atlassian
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentationTheo Schlossnagle
 
Puppet camp europe 2011 hackability
Puppet camp europe 2011   hackabilityPuppet camp europe 2011   hackability
Puppet camp europe 2011 hackability
Puppet
 
Einstein finalist.nl
Einstein finalist.nlEinstein finalist.nl
Einstein finalist.nl
Vincent Everts
 
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011Finalist - open IT oplossingen
 
Business of APIs Conference 2011 - YourTrove
Business of APIs Conference 2011 - YourTroveBusiness of APIs Conference 2011 - YourTrove
Business of APIs Conference 2011 - YourTrove
Mashery
 
Cochran - Mobile web 2 sms
Cochran - Mobile web 2 sms Cochran - Mobile web 2 sms
Cochran - Mobile web 2 sms
HR Florida State Council, Inc.
 

Similar to iPhone Python love affair (20)

Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
2011 The Year of Web apps
2011 The Year of Web apps2011 The Year of Web apps
2011 The Year of Web apps
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
Choosing the right Content Management System
Choosing the right Content Management SystemChoosing the right Content Management System
Choosing the right Content Management System
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
 
Sinsai.info と Crisis Mapping
Sinsai.info と Crisis Mapping Sinsai.info と Crisis Mapping
Sinsai.info と Crisis Mapping
 
Scaling atlassian os v4
Scaling atlassian os v4Scaling atlassian os v4
Scaling atlassian os v4
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applications
 
Koss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsKoss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser apps
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidia
 
Mobility in the financial industry
Mobility in the financial industryMobility in the financial industry
Mobility in the financial industry
 
iPhone App from concept to product
iPhone App from concept to productiPhone App from concept to product
iPhone App from concept to product
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patterns
 
Atlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide DeckAtlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide Deck
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentation
 
Puppet camp europe 2011 hackability
Puppet camp europe 2011   hackabilityPuppet camp europe 2011   hackability
Puppet camp europe 2011 hackability
 
Einstein finalist.nl
Einstein finalist.nlEinstein finalist.nl
Einstein finalist.nl
 
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011
Inspiratiemiddag_Vincent_Everts_Finalist generatie_einstein_komt_eraan_07042011
 
Business of APIs Conference 2011 - YourTrove
Business of APIs Conference 2011 - YourTroveBusiness of APIs Conference 2011 - YourTrove
Business of APIs Conference 2011 - YourTrove
 
Cochran - Mobile web 2 sms
Cochran - Mobile web 2 sms Cochran - Mobile web 2 sms
Cochran - Mobile web 2 sms
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 

iPhone Python love affair

  • 1. AN IPHONE-PYTHON LOVE AFFAIR Building APIs for Mobile Wednesday, June 8, 2011
  • 2. Music Hack Day, February 2011 Samantha & Matt Wednesday, June 8, 2011
  • 3. ACCOMPLICE #1 Anna Callahan: iOS developer, jazz trumpet player @jazztpt Wednesday, June 8, 2011
  • 4. ACCOMPLICE #2 Nate Aune: Django/Python/Plone developer, saxophonist @natea Wednesday, June 8, 2011
  • 7. MOBILE TAKEOVER If you’re not building for mobile now, you will be soon. Wednesday, June 8, 2011
  • 8. WHAT’S DIFFERENT ABOUT MOBILE? • Isn’t REST appropriate for everything? • Don’t I want a single API for all clients? Wednesday, June 8, 2011
  • 9. WHAT’S DIFFERENT ABOUT MOBILE? Mobile users are unwilling to wait. 1. Connection = slow, spotty, or non-existent 2. Mobile is not as powerful at fetching & saving data or calculations Wednesday, June 8, 2011
  • 10. SO YOUR API SHOULD • Return hierarchies of related data • Authentication and Authorization • Have mobile-specific error codes & messages • Accept arrays of related or unrelated data • Return pre-calculated data or data that doesn’t exist on device Wednesday, June 8, 2011
  • 11. HIERARCHIES OF DATA Bad :( Good! Cards Tracks Wednesday, June 8, 2011
  • 14. SIMPLE REST API Basic CRUD operations via API. Wednesday, June 8, 2011
  • 15. URLS.PY Now access cards and tracks with /api/card/ and /api/track/ Wednesday, June 8, 2011
  • 16. CREATE A CARD Wednesday, June 8, 2011
  • 17. WHAT ABOUT TRACKS? Default post_list from resources.py (create object via POST) Wednesday, June 8, 2011
  • 18. WHAT ABOUT TRACKS? api.py post_list (override method) Wednesday, June 8, 2011
  • 19. MOBILE WANTS HIERARCHICAL DATA Wednesday, June 8, 2011
  • 20. TASTYPIE MAKES IT EASY Wednesday, June 8, 2011
  • 21. AUTHENTICATION & AUTHORIZATION Authentication - let the user in the door Authorization - what the user can see Wednesday, June 8, 2011
  • 22. LIMITING BY USER Returns only the objects owned by the current user. Wednesday, June 8, 2011
  • 23. ERROR CODES Ideally your API should: •Never return HTML •Tailor response codes to actions on device •Return messages designed for the end user •Never, ever return HTML Wednesday, June 8, 2011
  • 24. JSON ERROR RESPONSES override wrap_view from resources.py Wednesday, June 8, 2011
  • 25. JSON ERROR HANDLING Objective-C in Xcode Wednesday, June 8, 2011
  • 27. ACCEPT ARRAYS OF DATA • User enters tunnel • User uses your app • User closes your app • User exits tunnel Wednesday, June 8, 2011
  • 28. PRE-CALCULATED DATA OR DATA NOT STORED ON DEVICE • No other users are stored on device • Leaderboards or other calculated user data must come from the server Wednesday, June 8, 2011
  • 29. THANK YOU! • Music Hack Day Accomplices: Matt Katz, Alexandre Passant, Jeff Novich, Twom Deryckere • Danielzilla (Daniel Lindsley) - TastyPie • IsaacKelly • DjangoCon Wednesday, June 8, 2011
  • 30. MORE INFO • Valentun.es live site http://valentun.es • Valentunes (Django code) https://github.com/natea/valentunes • Valentunes (iPhone code) https://github.com/jazztpt/Valentunes_iPhone • Valentunes (Twilio integration) https://github.com/terraces/valentunes-twilio Wednesday, June 8, 2011
  • 31. DJANGO API FRAMEWORKS • TastyPie documentation (the one we used) http://readthedocs.org/docs/django-tastypie/en/latest/ • django-piston https://bitbucket.org/jespern/django-piston/ • Django REST framework http://django-rest-framework.org Wednesday, June 8, 2011