Successfully reported this slideshow.

BrightonSEO 2020 - Mastering The API and Having Fun Along The Way

2

Share

Upcoming SlideShare
Collab - A dja
Collab - A dja
Loading in …3
×
1 of 71
1 of 71

More Related Content

BrightonSEO 2020 - Mastering The API and Having Fun Along The Way

  1. 1. defaced Mastering the API and having fun along the way.
  2. 2. defaced { "chris_johnson": { "work": "bamboo_nine", "twitter": "@defaced", "linkedin": "dfcd.co/linkedin", "slides": "dfcd.co/bseo-slides" } }
  3. 3. defaced APIs?!
  4. 4. defaced
  5. 5. defaced
  6. 6. defaced Mastering the API 1. Utilising existing APIs 2. 3. 4.
  7. 7. defaced Mastering the API 1. 2. Building your own 3. 4.
  8. 8. defaced Mastering the API 1. 2. 3. Supercharging your APIs 4.
  9. 9. defaced Mastering the API 1. 2. 3. 4. Having fun
  10. 10. defaced Not all APIs are created equal.
  11. 11. defaced Introducing… Ask An SEO.dev
  12. 12. defaced
  13. 13. defaced Q. Is * a ranking factor?
  14. 14. defaced A. …
  15. 15. defaced A. It depends.
  16. 16. defaced How can I access this resource? api.askanseo.dev
  17. 17. defaced POSTGET HTTP Methods
  18. 18. defaced import requests question = 'Is * a ranking factor?' response = requests.get('https://api.askanseo.dev/?question=' + question) # Returns true if a valid 200 response was sent. if response: # Print the JSON output. print(response.json()) else: # We didn't receive a valid 200 response. Handle the error. print(response.status_code) GET
  19. 19. defaced import requests request = {'question': 'Is * a ranking factor?’} response = requests.post('https://api.askanseo.dev/', json=request) # Returns true if a valid 200 response was sent. if response: # Print the JSON output. print(response.json()) else: # We didn't receive a valid 200 response. Handle our error. print(response.status_code) POST
  20. 20. defaced { "question": "is * a ranking factor?", "answer": "it depends" } RESPONSE
  21. 21. defaced Enhance your workflow with APIs.
  22. 22. defaced Metric: Transactions Dimension: Transaction ID
  23. 23. defaced
  24. 24. defaced Using Google Analytics Python API dfcd.co/dupe-check
  25. 25. defaced { 'reportRequests’: [ { 'viewId': analytics_view_id, 'dateRanges': [ {'startDate': start_date,'endDate': end_date} ], 'metrics': [{'expression': 'ga:transactions'}], 'dimensions': [{'name': 'ga:transactionId'}], 'pageSize': 1, 'orderBys': [ {'fieldName': 'ga:transactions','sortOrder': 'DESCENDING'} ] } ] }
  26. 26. defaced { "result": true } RESPONSE
  27. 27. defaced Building your own APIs.
  28. 28. defaced :~$ Move away from the CMD line.
  29. 29. defaced Serving your own API 1. On your desk 2. 3.
  30. 30. defaced Serving your own API 1. 2. Under your desk 3.
  31. 31. defaced Serving your own API 1. 2. 3. Under someone else’s desk* * Not an actual desk
  32. 32. defaced Google Cloud Functions. cloud.google.com/functions
  33. 33. defaced
  34. 34. defaced
  35. 35. defaced Your first cloud function. Ask An SEO API
  36. 36. defaced from flask import jsonify def api(request): # Retrieve our GET data request_args = request.args # Check to see if valid data was sent via GET if request_args and 'question' in request_args: q = request_args['question'] return jsonify(question=q, answer='it depends') # Otherwise reply with a 400 error else: return jsonify(error='bad request'), 400 GET
  37. 37. defaced from flask import jsonify def api(request): # Retrieve our POST data request_json = request.get_json() # Check to see if valid data was sent via POST if request_json and 'question' in request_json: q = request_json['question'] return jsonify(question=q, answer='it depends') # Otherwise reply with a 400 error else: return jsonify(error='bad request'), 400 POST
  38. 38. defaced question = 'Is * a ranking factor?' requests.get('https://cloud-function-url/api?question=' + question) GET
  39. 39. defaced request = {'question': 'Is * a ranking factor?’} requests.post('https://cloud-function-url/api', json=request) POST
  40. 40. defaced Request blocked. CORS the anti-fun policy
  41. 41. defaced Your second cloud function. JavaScript Difference’r
  42. 42. defaced
  43. 43. defaced Puppeteering from the clouds. dfcd.co/js-differ
  44. 44. defaced // Navigate to URL await page.goto(url) // Take an image with JavaScript const imageJavascript = await page.screenshot() // Disable JavaScript await page.setJavaScriptEnabled(false) // Navigate to URL await page.goto(url) // Take an image without JavaScript const imageNoJavascript = await page.screenshot()
  45. 45. defaced
  46. 46. defaced This sounds expensive!
  47. 47. defaced Layout Shift GIF Generator. dfcd.co/layout-shift
  48. 48. defaced Over 4,500 GIFs generated. £1.60
  49. 49. defaced Supercharging your APIs.
  50. 50. defaced Automate your workflow.
  51. 51. defaced Save every API response.
  52. 52. defaced Compare with your last saved response. dfcd.co/dict-differ
  53. 53. defaced If there’s a difference, do something. dfcd.co/slack-api
  54. 54. defaced Visualise your API toolkit. Dashboards and widgets
  55. 55. defaced
  56. 56. defaced Get creative. @theshapeofashow
  57. 57. defaced
  58. 58. defaced Halt and Catch Fire Season 1 - 4
  59. 59. defaced Bounce Rate 2017 - 2019
  60. 60. defaced Introducing… Printerbot
  61. 61. defaced
  62. 62. defaced API driven. Web connected. Thermal printer.
  63. 63. defaced
  64. 64. defaced
  65. 65. defaced Oops.
  66. 66. defaced Gameboy Camera & Printerbot.
  67. 67. defaced
  68. 68. defaced Live demo. @defaced
  69. 69. defaced
  70. 70. defaced
  71. 71. defaced Thank you. dfcd.co/bseo-slides

×