SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Downloaden Sie, um offline zu lesen
Mashing up

        Michael Brunton-Spall
michael.brunton-spall@guardian.co.uk
            @mibgames
About Us

 Online since 1995
 250M+ pages per month
 30M+ visitors per month
1995 - Guardian Online
1999 - Guardian Unlimited
1999 - Removed the registration wall
2007 - Rebuild and Redesign
2007 - Rebuild and Redesign
2007 - Rebuild and Redesign
2009 - MPs Expenses
Developing The Guardian
The Hackable Guardian

 Url Hacking
 Keyword Combiners
 RSS Feeds
Url Hacking

http://www.guardian.co.uk/
    [section]/[keyword]
        technology/internet
    [section]/all
        environment/all
     [publication]/[date]/[newspapersection]
        theguardian/2009/jun/11/technologyguardian
    profile/[name]
        profile/bobbiejohnson
RSS Feeds

RSS Everywhere!
  [section]/[keyword]/rss
      technology/internet/rss
  [section]/all /rss
      environment/all/rss
   [publication]/[date]/[newspapersection]/rss
      theguardian/2009/jun/11/technologyguardian/rss
  profile/[name]/rss
      profile/bobbiejohnson/rss
Full Fat!


http://www.flickr.com/photos/snapperwolf/
Url Combiners

  A Logical AND
  Almost any combination from before
     technology/internet+profile/bobbiejohnson
     theguardian/technologyguardian+technology/internet
  Except things that aren't actual tags:
     Dated newspaper sections
        theguardian/2009/jun/11... + anything = 404
     the all page
        .../all + anything = 404
Problems with this approach

  Fragile
  No Discovery
  Not well documented
  Copyright Issues
Build applications with the Guardian
Open Platform

  Opening up how we work with people both internally
  and externally
  A suite of services enabling partners to build
  applications with the Guardian
     Content API
     Data Store
Data Store
  A directory of useful data curated by Guardian editors
Data Store
  A directory of useful data curated by Guardian editors
Data Store
Data Store
Content API

  A service for selecting and collecting content from the
  Guardian for re-use
Content API

  A service for selecting and collecting content from the
  Guardian for re-use
Content API




              Search content
Content API




              Xml and Json
Content API




              Tag Metadata
Content API




              Full Article Body
Content API




              Filters
So why?


 guardian.co.uk has an amazing amount of
 quality content
 Incredible amounts of meta-data, curated by
 editors
 Aim to allow the guardian to become a rich
 source of facts and journalism for the web
How?
 Backed of our search platform
 Provides access to 10 years of article content and
 metadata
 Supports multiple output formats: XML, JSON, ATOM
 Supported free text search across content
 Search for keywords
 Guardian supported api projects in Java, PHP, Python
 and Ruby
 Community supported api projects in Perl, ActionScript
 and Coldfusion (and probably more?)
Pricing
Pricing




          FREE!
How free is free?

  You can publish full articles from the guardian on your
  website
  5k queries per day limit
  24 hour maximum cache lifetime
  Online support
  Partner with us on advertising
Beta trial


  Limited number of keys
  Collecting feedback
  Will open more widely at end of beta program
How do I use it?

  Home page
     http://www.guardian.co.uk/open-platform
  Sign up for an API key at
     http://guardian.mashery.com
  Use the API Explorer at
     http://api.guardianapis.com/docs/
  Use the python library at
     http://code.google.com/p/openplatform-python/
What can I do with it?


  Search our tag hierarchy
  Find content by tag
  Find content by search terms




         Display on your website!
MP's Expenses
MP's Expenses

 Written in Django
 Hosted on EC2
 Easy to modify
 Written in 2 weeks
MP's Expenses




                An MP's Page
View

def mp(request, id):
  mp = get_object_or_404(MP, pk = id)
  ...

  return render(request, 'mp.html', {
     'mp': mp,
     'documents': mp.documents.all(),
     'top_users': top_users[:5],
  })
View

def mp(request, id):
  mp = get_object_or_404(MP, pk = id)
  ...

  return render(request, 'mp.html', {
     'mp': mp,
     'documents': mp.documents.all(),
     'top_users': top_users[:5],
  })
View

def mp(request, id):
  mp = get_object_or_404(MP, pk = id)
  ...

  return render(request, 'mp.html', {
     'mp': mp,
     'documents': mp.documents.all(),
     'top_users': top_users[:5],
  })
Using the Guardian API

  Getting all articles about an MP
     results = client.search(q='"%S"' % (name))
     returns a paginating iterator
     for x in results:
         print x['headline']
     Shows only first 10 by default
Get the client

def mp(request, id):
  mp = get_object_or_404(MP, pk = id)
  ...
  client = Client(settings.GUARDIAN_APIKEY)

  return render(request, 'mp.html', {
     'mp': mp,
     'documents': mp.documents.all(),
     'top_users': top_users[:5],
  })
Make the request

def mp(request, id):
  mp = get_object_or_404(MP, pk = id)
  ...
  client = Client(settings.GUARDIAN_APIKEY)

  return render(request, 'mp.html', {
     'mp': mp,
     'documents': mp.documents.all(),
     'top_users': top_users[:5],
     'articles': client.search(q='"%s"'%(mp.name)),
  })
Update the template

<div id="about-mp">
  <ul>
     {% for article in articles %}
     <li>
        <a href="{{article.webUrl}}">{{article.headline}}</a>
     </li>
     {% endfor %}
  </ul>
</div>
And the result!
Additions?

  Use Memcached to cache the response from guardian API
  Don't create a new client each time
  Article bodies
Who else is using it?
Who else is using it?
Who else is using it?
Who else is using it?
Public API Key?

 jbynv3fwdp8ju5625mt2axw3
 Only 5k queries a day
 Will be closed on Friday 14th August
 Will be closed if abused
 Strongly encourage you to sign up for your own key
Questions?
Mashing up

        Michael Brunton-Spall
michael.brunton-spall@guardian.co.uk
         twitter: @mibgames

Weitere ähnliche Inhalte

Andere mochten auch

Grandes cosas ocurren cuando dios se junta con el hombre visita de swami ...
Grandes cosas ocurren cuando dios  se junta con el hombre    visita de swami ...Grandes cosas ocurren cuando dios  se junta con el hombre    visita de swami ...
Grandes cosas ocurren cuando dios se junta con el hombre visita de swami ...
CENTRO SAI HISPANO
 
MMI África - Universidades en Nigeria
MMI África - Universidades en NigeriaMMI África - Universidades en Nigeria
MMI África - Universidades en Nigeria
GlocalUp
 
Le Nouveau LycéE GéNéRal Et Technologique[1]
Le Nouveau LycéE GéNéRal Et Technologique[1]Le Nouveau LycéE GéNéRal Et Technologique[1]
Le Nouveau LycéE GéNéRal Et Technologique[1]
isport
 
Résultats enquête citoyens Développement Durable
Résultats enquête citoyens Développement DurableRésultats enquête citoyens Développement Durable
Résultats enquête citoyens Développement Durable
Rouen
 

Andere mochten auch (20)

From Publisher To Platform: How The Guardian Used Content, Search, and Open S...
From Publisher To Platform: How The Guardian Used Content, Search, and Open S...From Publisher To Platform: How The Guardian Used Content, Search, and Open S...
From Publisher To Platform: How The Guardian Used Content, Search, and Open S...
 
Guardian at MediaCom Engage October 2013
Guardian at MediaCom Engage October 2013Guardian at MediaCom Engage October 2013
Guardian at MediaCom Engage October 2013
 
WVPDX 2014 - Hammering Responsive Web Design Into Shape
WVPDX 2014 - Hammering Responsive Web Design Into ShapeWVPDX 2014 - Hammering Responsive Web Design Into Shape
WVPDX 2014 - Hammering Responsive Web Design Into Shape
 
Comunicación y Diseño para el Desarrollo. Caso: Entre soles y lunas
Comunicación y Diseño para el Desarrollo. Caso: Entre soles y lunasComunicación y Diseño para el Desarrollo. Caso: Entre soles y lunas
Comunicación y Diseño para el Desarrollo. Caso: Entre soles y lunas
 
Grandes cosas ocurren cuando dios se junta con el hombre visita de swami ...
Grandes cosas ocurren cuando dios  se junta con el hombre    visita de swami ...Grandes cosas ocurren cuando dios  se junta con el hombre    visita de swami ...
Grandes cosas ocurren cuando dios se junta con el hombre visita de swami ...
 
MMI África - Universidades en Nigeria
MMI África - Universidades en NigeriaMMI África - Universidades en Nigeria
MMI África - Universidades en Nigeria
 
Le Nouveau LycéE GéNéRal Et Technologique[1]
Le Nouveau LycéE GéNéRal Et Technologique[1]Le Nouveau LycéE GéNéRal Et Technologique[1]
Le Nouveau LycéE GéNéRal Et Technologique[1]
 
Beyond Ausgabe #4 – Leseprobe
Beyond Ausgabe #4 – LeseprobeBeyond Ausgabe #4 – Leseprobe
Beyond Ausgabe #4 – Leseprobe
 
Day1 sp2 babatunde-icgfmpp_sp
Day1 sp2 babatunde-icgfmpp_spDay1 sp2 babatunde-icgfmpp_sp
Day1 sp2 babatunde-icgfmpp_sp
 
Résultats enquête citoyens Développement Durable
Résultats enquête citoyens Développement DurableRésultats enquête citoyens Développement Durable
Résultats enquête citoyens Développement Durable
 
UXPA Dallas - Google Analytics and What's Before Mobile First
UXPA Dallas - Google Analytics and What's Before Mobile FirstUXPA Dallas - Google Analytics and What's Before Mobile First
UXPA Dallas - Google Analytics and What's Before Mobile First
 
Marc Durand - Le point sur Anticosti et enjeux des EES en cours
Marc Durand - Le point sur Anticosti et enjeux des EES en coursMarc Durand - Le point sur Anticosti et enjeux des EES en cours
Marc Durand - Le point sur Anticosti et enjeux des EES en cours
 
Welche Rolle passt zu welcher Situation? Entdecken Sie Ihre eigenen Rollen!
Welche Rolle passt zu welcher Situation? Entdecken Sie Ihre eigenen Rollen! Welche Rolle passt zu welcher Situation? Entdecken Sie Ihre eigenen Rollen!
Welche Rolle passt zu welcher Situation? Entdecken Sie Ihre eigenen Rollen!
 
Collaboration between project management and developers
Collaboration between project management and developersCollaboration between project management and developers
Collaboration between project management and developers
 
Q2 Presentation
Q2 PresentationQ2 Presentation
Q2 Presentation
 
Pareto securities corporate bond conference 23 January 2014
Pareto securities corporate bond conference 23 January 2014Pareto securities corporate bond conference 23 January 2014
Pareto securities corporate bond conference 23 January 2014
 
Pareto E&P conference PA Resources
Pareto E&P conference PA ResourcesPareto E&P conference PA Resources
Pareto E&P conference PA Resources
 
Erweitern sie ihr Data Center mit Cloud Services
Erweitern sie ihr Data Center mit Cloud ServicesErweitern sie ihr Data Center mit Cloud Services
Erweitern sie ihr Data Center mit Cloud Services
 
PA Resources Q4 Interim report
PA Resources Q4 Interim report PA Resources Q4 Interim report
PA Resources Q4 Interim report
 
Unternehmensuebergreifendes Projektmanagement
Unternehmensuebergreifendes ProjektmanagementUnternehmensuebergreifendes Projektmanagement
Unternehmensuebergreifendes Projektmanagement
 

Ähnlich wie Mashing Up The Guardian

Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
Ganga Ram
 

Ähnlich wie Mashing Up The Guardian (20)

Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Api's and ember js
Api's and ember jsApi's and ember js
Api's and ember js
 
apidays Paris 2022 - France Televisions : How we leverage API Platform for ou...
apidays Paris 2022 - France Televisions : How we leverage API Platform for ou...apidays Paris 2022 - France Televisions : How we leverage API Platform for ou...
apidays Paris 2022 - France Televisions : How we leverage API Platform for ou...
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
Yahoo is open to developers
Yahoo is open to developersYahoo is open to developers
Yahoo is open to developers
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Need for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsNeed for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API Projects
 
Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping
 
CCCDjango2010.pdf
CCCDjango2010.pdfCCCDjango2010.pdf
CCCDjango2010.pdf
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Benefits of the CodeIgniter Framework
Benefits of the CodeIgniter FrameworkBenefits of the CodeIgniter Framework
Benefits of the CodeIgniter Framework
 
Building a Bank with Go
Building a Bank with GoBuilding a Bank with Go
Building a Bank with Go
 
Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Adopting F# at SBTech
Adopting F# at SBTechAdopting F# at SBTech
Adopting F# at SBTech
 
Making the most out of kubernetes audit logs
Making the most out of kubernetes audit logsMaking the most out of kubernetes audit logs
Making the most out of kubernetes audit logs
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
IBM Omnifind Enterprise Portal Seach To Improve Productivity
IBM Omnifind Enterprise   Portal Seach To Improve ProductivityIBM Omnifind Enterprise   Portal Seach To Improve Productivity
IBM Omnifind Enterprise Portal Seach To Improve Productivity
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Mashing Up The Guardian

  • 1. Mashing up Michael Brunton-Spall michael.brunton-spall@guardian.co.uk @mibgames
  • 2. About Us Online since 1995 250M+ pages per month 30M+ visitors per month
  • 4. 1999 - Guardian Unlimited
  • 5. 1999 - Removed the registration wall
  • 6. 2007 - Rebuild and Redesign
  • 7. 2007 - Rebuild and Redesign
  • 8. 2007 - Rebuild and Redesign
  • 9. 2009 - MPs Expenses
  • 11. The Hackable Guardian Url Hacking Keyword Combiners RSS Feeds
  • 12. Url Hacking http://www.guardian.co.uk/ [section]/[keyword] technology/internet [section]/all environment/all [publication]/[date]/[newspapersection] theguardian/2009/jun/11/technologyguardian profile/[name] profile/bobbiejohnson
  • 13. RSS Feeds RSS Everywhere! [section]/[keyword]/rss technology/internet/rss [section]/all /rss environment/all/rss [publication]/[date]/[newspapersection]/rss theguardian/2009/jun/11/technologyguardian/rss profile/[name]/rss profile/bobbiejohnson/rss
  • 15.
  • 16.
  • 17. Url Combiners A Logical AND Almost any combination from before technology/internet+profile/bobbiejohnson theguardian/technologyguardian+technology/internet Except things that aren't actual tags: Dated newspaper sections theguardian/2009/jun/11... + anything = 404 the all page .../all + anything = 404
  • 18. Problems with this approach Fragile No Discovery Not well documented Copyright Issues
  • 19. Build applications with the Guardian
  • 20. Open Platform Opening up how we work with people both internally and externally A suite of services enabling partners to build applications with the Guardian Content API Data Store
  • 21. Data Store A directory of useful data curated by Guardian editors
  • 22. Data Store A directory of useful data curated by Guardian editors
  • 25. Content API A service for selecting and collecting content from the Guardian for re-use
  • 26. Content API A service for selecting and collecting content from the Guardian for re-use
  • 27. Content API Search content
  • 28. Content API Xml and Json
  • 29. Content API Tag Metadata
  • 30. Content API Full Article Body
  • 31. Content API Filters
  • 32. So why? guardian.co.uk has an amazing amount of quality content Incredible amounts of meta-data, curated by editors Aim to allow the guardian to become a rich source of facts and journalism for the web
  • 33. How? Backed of our search platform Provides access to 10 years of article content and metadata Supports multiple output formats: XML, JSON, ATOM Supported free text search across content Search for keywords Guardian supported api projects in Java, PHP, Python and Ruby Community supported api projects in Perl, ActionScript and Coldfusion (and probably more?)
  • 35. Pricing FREE!
  • 36. How free is free? You can publish full articles from the guardian on your website 5k queries per day limit 24 hour maximum cache lifetime Online support Partner with us on advertising
  • 37. Beta trial Limited number of keys Collecting feedback Will open more widely at end of beta program
  • 38. How do I use it? Home page http://www.guardian.co.uk/open-platform Sign up for an API key at http://guardian.mashery.com Use the API Explorer at http://api.guardianapis.com/docs/ Use the python library at http://code.google.com/p/openplatform-python/
  • 39. What can I do with it? Search our tag hierarchy Find content by tag Find content by search terms Display on your website!
  • 41. MP's Expenses Written in Django Hosted on EC2 Easy to modify Written in 2 weeks
  • 42. MP's Expenses An MP's Page
  • 43. View def mp(request, id): mp = get_object_or_404(MP, pk = id) ... return render(request, 'mp.html', { 'mp': mp, 'documents': mp.documents.all(), 'top_users': top_users[:5], })
  • 44. View def mp(request, id): mp = get_object_or_404(MP, pk = id) ... return render(request, 'mp.html', { 'mp': mp, 'documents': mp.documents.all(), 'top_users': top_users[:5], })
  • 45. View def mp(request, id): mp = get_object_or_404(MP, pk = id) ... return render(request, 'mp.html', { 'mp': mp, 'documents': mp.documents.all(), 'top_users': top_users[:5], })
  • 46. Using the Guardian API Getting all articles about an MP results = client.search(q='"%S"' % (name)) returns a paginating iterator for x in results: print x['headline'] Shows only first 10 by default
  • 47. Get the client def mp(request, id): mp = get_object_or_404(MP, pk = id) ... client = Client(settings.GUARDIAN_APIKEY) return render(request, 'mp.html', { 'mp': mp, 'documents': mp.documents.all(), 'top_users': top_users[:5], })
  • 48. Make the request def mp(request, id): mp = get_object_or_404(MP, pk = id) ... client = Client(settings.GUARDIAN_APIKEY) return render(request, 'mp.html', { 'mp': mp, 'documents': mp.documents.all(), 'top_users': top_users[:5], 'articles': client.search(q='"%s"'%(mp.name)), })
  • 49. Update the template <div id="about-mp"> <ul> {% for article in articles %} <li> <a href="{{article.webUrl}}">{{article.headline}}</a> </li> {% endfor %} </ul> </div>
  • 51. Additions? Use Memcached to cache the response from guardian API Don't create a new client each time Article bodies
  • 52. Who else is using it?
  • 53. Who else is using it?
  • 54. Who else is using it?
  • 55. Who else is using it?
  • 56. Public API Key? jbynv3fwdp8ju5625mt2axw3 Only 5k queries a day Will be closed on Friday 14th August Will be closed if abused Strongly encourage you to sign up for your own key
  • 58. Mashing up Michael Brunton-Spall michael.brunton-spall@guardian.co.uk twitter: @mibgames