external apis and drupal
play

External APIs and Drupal Strategies for Integrating External API - PowerPoint PPT Presentation

External APIs and Drupal Strategies for Integrating External API Data Introductions Luke Bainbridge lbainbridge (drupal.org) @midnightLuke (twitter) Topics Drupal and APIs Data APIs The API landscape Caching


  1. External APIs and Drupal Strategies for Integrating External API Data

  2. Introductions ● Luke Bainbridge ● lbainbridge (drupal.org) ● @midnightLuke (twitter)

  3. Topics ● Drupal and APIs ● Data APIs ● The API landscape ● Caching strategy and implementation ● There will be ONE lolcat...

  4. Data APIs ● Great way to add relevant information to your site ● Can create richer content ● Can cause painful lag ● Lack of industry standards can cause headaches ● All APIs are different and require different approaches

  5. Drupal and APIs ● Services module can create powerful APIs ○ Services Entity ○ Services Views ○ oAuth ○ Services Token Access ● Drupal as a consumer ○ Suffers the same issues mentioned before ○ drupal_http_request() is swiss army chainsaw ■ ...or cUrl

  6. The Problem... ● Extremely large dataset, accessible over API ● Data needs to be very current ● Some pages require large amount of API calls

  7. The Solutions Depend on the API ● Duplicate the data in Drupal ● Source data on request-by-request basis ● Build remote entity controller ● Use vendor widget ● Link to the external data source

  8. Duplicate Data in Drupal ● All Drupal functionality and modules available ● How do you keep data current? ● Can you obtain a list of resources?

  9. Remote Entity Controller ● Work is being done to make this a reality! ○ Remote Entity API module ● Will depend heavily on a flexible API ● Local fields are possible ○ Wunderkraut’s blog on the subject

  10. Our Solution ● Source data during page request ● Cache responses using drupal’s cache functionality ● Provide abstract class for caching to allow many different API implementations to store responses ● Use database abstraction conventions

  11. The Response Cache ● A successful request is stored in the cache ○ “Successful” is API dependant ● Cache should be tuned to application and flushable ● A cached response may affect the entire site ● Responses can be manipulated in a variety of ways

  12. Why Not the Page Cache? ● No gain for authenticated traffic ● No gain for common site-wide API calls ● Rate-limiting APIs ● You can still use it later!

  13. Example: iTunes API ● Documentation: ○ http://www.apple. com/itunes/affiliates/resources/documentation/it unes-store-web-service-search-api.html ● Sandbox module ○ https://drupal.org/sandbox/lbainbridge/2152595

  14. Tips ● Try to get everything in one request ● The static cache is your friend ○ drupal_static(__FUNCTION__) ● Be creative with files ○ Check timestamps ○ Queue updates to files ● Cache pages as well when possible

  15. Conclusion ● APIs are powerful ● APIs are frustrating ● APIs are your friend

  16. Questions? Discussion?

Recommend


More recommend