SlideShare a Scribd company logo
How Anyone Can Leverage APIs for SEO
Paul Shapiro
#TTTLIVE19
Paul Shapiro
Partner, Director of Strategy & Innovation /
SEO Practice Lead @ Catalyst
#TTTLIVE19
#TTTLIVE19
#TTTLIVE19
WTF is an API!?
(RESTful Web API)
#TTTLIVE19
Application Programming
Interface
#TTTLIVE19
Basically, APIs provide you a way to
interface with an external web service.
This enables automation,
permits you to incorporate 3rd party systems
into your own application,
and to expand both systems by combining
those services and features.
#TTTLIVE19
So, how does this work exactly?
#TTTLIVE19
SERVER
HTTP is the protocol that
facilitates communication
between the client computer and
server computer via requests
and responses
#TTTLIVE19
CRUD Operations:
Create
Read
Update
Delete
Operation SQL HTTP
RESTful Web
Services
Create INSERT PUT / POST POST
Read (Retrieve) SELECT GET GET
Update (Modify) UPDATE
PUT / POST / PAT
CH
PUT
Delete (Destroy) DELETE DELETE DELETE
https://en.wikipedia.org/wiki/Create,_read,_update_and_de
lete
#TTTLIVE19
The interaction between client and server can
be facilitated via several structured methods
(sometimes referred to as verbs).
#TTTLIVE19
GET and POST are the most common methods
and commonly used in conjunction with web
APIs.
#TTTLIVE19
#TTTLIVE19
• “GET is used to request data from a
specified resource.”
• “POST is used to send data to a server to
create/update a resource.”
https://www.w3schools.com/tags/ref_httpmethods.asp
#TTTLIVE19
• “PUT is used to send data to a server to
create/update a resource.”
• “DELETE method deletes the specified
resource.”
https://www.w3schools.com/tags/ref_httpmethods.asp
#TTTLIVE19
#TTTLIVE19
APIs are a little bit like this antiquated ordering system…
1. You need to look at available inventory. You look at Spice
Company’s catalogue via the GET method. This gives them
a list of products they can order.
2. Once you know what you would like to purchase, your
internal system marks it down according to some pre-
defined business logic (in the form of item numbers and
corresponding quantities)
3. Your program places and order sending this payload to the
corresponding API endpoint using the POST method and
you receive the product at your physical address sometime
after.
#TTTLIVE19
{
"accountId": "8675309",
"shipAddress":
{ "name": "Bob SpiceyMcSpiceFace",
"address": "237 South Broad Street",
"city": "Philadelphia",
"state": "PA"
}
"order":
{
"itemNumber": 86,
"quantity": 5
}
}
#TTTLIVE19
API Endpoint:
http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&
q=board%20games
Variable,
encoded
Simple API example via GET request
#TTTLIVE19
Response (XML):
#TTTLIVE19
Parse the XML
board games
board games for kids
board games for adults
board games near me
board games online
board games list
board games walmart
board games boston
board games 2018
board games for toddlers
#TTTLIVE19
Answer The Public?
Ubersuggest?
Keywordtool.io
http://suggestqueries.google.co
m/complete/search?output=tool
bar&hl=en&q=board%20games
• q=board%20games%20can
• q=board%20games%20vs
• q=how%20board%20games
#TTTLIVE19
API Endpoint:
http://api.grepwords.com/lookup?apikey=api_key_string&q=keyword
String is unique
to you, like
password
(authentication)
Variable,
changes
and often
looped
Simple API example via GET request
(with authentication)
#TTTLIVE19
http://api.grepwords.com/lookup?apikey=secret&q=board+games
Response (JSON):
[{"keyword":"board games","updated_cpc":"2018-04-30","updated_cmp":"2018-04-
30","updated_lms":"2018-04-30","updated_history":"2018-04-
30","lms":246000,"ams":246000,"gms":246000,"competition":0.86204091185173,"competeti
on":0.86204091185173,"cmp":0.86204091185173,"cpc":0.5,"m1":201000,"m1_month":"2018-
02","m2":246000,"m2_month":"2018-01","m3":450000,"m3_month":"2017-
12","m4":368000,"m4_month":"2017-11","m5":201000,"m5_month":"2017-
10","m6":201000,"m6_month":"2017-09","m7":201000,"m7_month":"2017-
08","m8":201000,"m8_month":"2017-07","m9":201000,"m9_month":"2017-
06","m10":201000,"m10_month":"2017-05","m11":201000,"m11_month":"2017-
04","m12":201000,"m12_month":"2017-03"}]
Simple API example via GET request
#TTTLIVE19
Parse the JSON
keyword gms
board games 246,000
#TTTLIVE19
https://www.catalystdigital.com
/techseoboost/
#TTTLIVE19
Full Python Script
(GrepWords/JSON):
import requests
import json
boardgames = ["Gaia Project", "Great Western Trail", "Spirit
Island"]
for x in boardgames:
apiurl = "http://api.grepwords.com/lookup?apikey=key&q=" + x
r = requests.get(apiurl)
parsed_json = json.loads(r.text)
print(parsed_json[0]['gms'])
1
2
3
4
5
6
7
8
#TTTLIVE19
#TTTLIVE19
Full Python Script (Google Autosuggest/XML):
import requests
import xml.etree.ElementTree as ET
boardgames = ["Gaia Project", "Great Western Trail", "Spirit Island"]
for x in boardgames:
apiurl = "http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=" + x
r = requests.get(apiurl)
tree = ET.fromstring(r.content)
for child in tree.iter('suggestion'):
print(child.attrib['data'])
#TTTLIVE19
#TTTLIVE19
Combine Them Together?
import requests
import xml.etree.ElementTree as ET
import json
boardgames = ["board game", "bgg", "board game geek"]
for x in boardgames:
suggest_url =
"http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=" + x
r = requests.get(suggest_url)
tree = ET.fromstring(r.content)
for child in tree.iter('suggestion'):
print(child.attrib['data'])
grep_url = "http://api.grepwords.com/lookup?apikey=key&q=" + child.attrib['data']
r = requests.get(grep_url)
parsed_json = json.loads(r.text)
try:
print(parsed_json[0]['gms'])
except KeyError:
print("No data available in GrepWords.")
#TTTLIVE19
#TTTLIVE19
Google Autocomplete ✓
#TTTLIVE19
GrepWords ✓
#TTTLIVE19
Other API Examples
#TTTLIVE19
WebPageTest.org
#TTTLIVE19
import requests
import json
import xml.etree.ElementTree as ET
import time
testurls = ["https://searchwilderness.com/", "https://trafficthinktank.com/", "https://searchengineland.com/"]
for x in testurls:
apiurl = "http://www.webpagetest.org/runtest.php?fvonly=1&k=KEY&lighthouse=1&f=xml&url=" + x
r = requests.get(apiurl)
tree = ET.fromstring(r.content)
for child in tree.findall('data'):
wpturl = child.find('jsonUrl').text
print(wpturl)
ready = True
while ready:
r = requests.get(wpturl)
parsed_json = json.loads(r.text)
try:
if(parsed_json['data']['statusCode']==100):
print("Not yet ready. Trying again in 20 seconds.")
ready = True
time.sleep(20)
except KeyError:
ready = False
print(x + "rn")
print("Lighthouse Average First Contentful Paint: " +
str(parsed_json['data']['average']['firstView']['chromeUserTiming.firstContentfulPaint']))
#TTTLIVE19
SEMRush
#TTTLIVE19
import csv
import requests
domain = “trafficthinktank.com"
key = "YOUR API KEY"
api_url = "https://api.semrush.com/?type=domain_organic&key=" + key +
"&display_filter=%2B%7CPh%7CCo%7Cseo&display_limit=10&export_columns=Ph,Po,Pp,Pd,Nq,Cp,
Ur,Tr,Tc,Co,Nr,Td&domain=" + domain + "&display_sort=tr_desc&database=us"
with requests.Session() as s:
download = s.get(api_url)
decoded_content = download.content.decode('utf-8')
cr = csv.reader(decoded_content.splitlines(), delimiter=';')
my_list = list(cr)
for column in my_list:
print(column[0]) # Keyword
print(column[1]) # Position
print(column[4]) # Search Volume
print(column[6]) # URL
#TTTLIVE19
Google Analytics?
#TTTLIVE19
Sample Code:
https://developers.google.com/analyti
cs/devguides/reporting/core/v4/quicks
tart/installed-py
JSON Payload Help: https://ga-dev-
tools.appspot.com/query-explorer/
#TTTLIVE19
Moz (Linkscape)
#TTTLIVE19
from mozscape import Mozscape
import pandas as pd
import numpy as np
import requests
import time
def divide_chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
client = Mozscape('access_id', 'sectet_key')
csv = pd.read_csv('./all_outlinks.csv', skiprows=1)
links = csv[csv['Type'] == 'AHREF']
# filter out CDNs, self-references, and other known cruft
links = csv[~csv['Destination'].str.match('https?://boardgamegeek.com.*')]
Domains = links['Destination'].replace(to_replace="(.*://)?([^/?]+).*", value=r"12", regex=True)
x = list(divide_chunks(Domains.unique().tolist(), 5))
df = pd.DataFrame(columns=['pda','upa','url'])
for vals in x:
da_pa = client.urlMetrics(vals, Mozscape.UMCols.domainAuthority | Mozscape.UMCols.pageAuthority)
i = 0
for y in da_pa:
y['url'] = vals[i]
i = i+1
df = df.append(y, ignore_index=True)
print("Processing a batch of 5 URLs. Total URLs: " + str(len(Domains.unique())))
time.sleep(5)
print(df)
https://github.com/seomoz/SEOmozAPISamples
/tree/master/python
#TTTLIVE19
Search Console
#TTTLIVE19
Schedule to run monthly with Cron and
backup to SQL database:
https://searchwilderness.com/gwmt-
data-python/
JR Oakes’ BigQuery vision:
http://bit.ly/2vmjDe8
#TTTLIVE19
Webhose.io
#TTTLIVE19
import requests
import json
import datetime
import urllib.parse
apikey = "KEY"
search = 'title:"board games" -shipping -sale site_type:news language:english'
query = urllib.parse.quote(search)
time_diff = -30
time = int((dt.datetime.now(dt.timezone.utc) + dt.timedelta(time_diff)).timestamp())
apiurl = "http://webhose.io/filterWebContent?token=" + apikey + "&format=json&ts=" + str(time) +
"&sort=crawled&q=" + query
r = requests.get(apiurl)
parsed_json = json.loads(r.text)
for i in range(int(parsed_json['totalResults'])):
try:
print(parsed_json['posts'][i]['title'])
print(parsed_json['posts'][i]['thread']['social']['facebook'])
except IndexError:
print("error occurred")
#TTTLIVE19
Reddit
#TTTLIVE19
https://searchwilderness.com/
reddit-python-code/
#TTTLIVE19
Wayback Machine
#TTTLIVE19
import requests
import json
domain = "trafficthinktank.com"
apiurl = "https://web.archive.org/cdx/search/cdx?url=" + domain +
"&matchType=domain&fl=original,timestamp&collapse=urlkey&filter=mi
metype:text/html&filter=!original:.*%3A80.*&filter=!original:.*.(p
ng%7Cjs%7Ccss%7Cjpg%7Csvg%7Cjpeg%7Cgif%7Cxml%7Crss%7CPNG%7CJS%7CCS
S%7CJPG%7CSVG%7CJPEG%7CGIF%7CXML%7CRSS%7Ctxt%7CTXT%7Cico%7CICO%7Cp
df%7CPDF).*&output=json"
r = requests.get(apiurl)
parsed_json = json.loads(r.text)
for x in range(int(len(parsed_json))):
print(parsed_json[x][0])
#TTTLIVE19
Other APIs
• STAT / Rank Tracking
• Google Natural Language Processing
• Various Machine Learning Services
• DeepCrawl / Botify / Cloud Crawlers
• Stripe (for payment)
• Map / Geolocation Data (Google Maps/Foursquare)
• Slack
• Whois data
#TTTLIVE19
Putting things together and making magic
#TTTLIVE19
1. Take outlink report
from Screaming Frog
2. Distills URLs to
Domains
3. Runs Moz Linkscape
API against the list for
PA & DA
4. Checks HTTP Status
Code
5. Runs WHOIS API to
see if domain is
available
https://gist.github.com/pshapiro/819cd172f
f8fe576f2a4e1f74395ec47
#TTTLIVE19
https://github.com/MLTSEO/MLTS
#TTTLIVE19
Thanks!
TTT: @Paul Shapiro
Twitter: @fighto
Blog: SearchWilderness.com

More Related Content

PDF
GraphQL - when REST API is to less - lessons learned
PDF
Deliver Business Value Faster with AWS Step Functions
PDF
Chatting with HIpChat: APIs 101
PDF
[DevCrowd] GraphQL - gdy API RESTowe to za mało
PDF
Enter the app era with ruby on rails
PDF
GraphQL - when REST API is to less - lessons learned
PDF
BruJUG Brussels GraphQL when RESR API is to less - lessons learned
PDF
RESTful Web API and MongoDB go for a pic nic
GraphQL - when REST API is to less - lessons learned
Deliver Business Value Faster with AWS Step Functions
Chatting with HIpChat: APIs 101
[DevCrowd] GraphQL - gdy API RESTowe to za mało
Enter the app era with ruby on rails
GraphQL - when REST API is to less - lessons learned
BruJUG Brussels GraphQL when RESR API is to less - lessons learned
RESTful Web API and MongoDB go for a pic nic

What's hot (6)

PDF
What's Your Problem?
PDF
From CRUD to Hypermedia APIs with Spring
PDF
Building Awesome API with Spring
PDF
"From CRUD to Hypermedia APIs with Spring" Владимир Цукур
PDF
What’s Your Problem?
PDF
[2019 south bay meetup] Building more contextual message with Block Kit
What's Your Problem?
From CRUD to Hypermedia APIs with Spring
Building Awesome API with Spring
"From CRUD to Hypermedia APIs with Spring" Владимир Цукур
What’s Your Problem?
[2019 south bay meetup] Building more contextual message with Block Kit
Ad

Similar to How to Leverage APIs for SEO #TTTLive2019 (20)

PPTX
Getting to Grips with RESTful APIs
ZIP
The Power of Open Data
KEY
Enter the app era with ruby on rails (rubyday)
PPTX
RESTful modules in zf2
PDF
API management with Taffy and API Blueprint
PDF
Seamless and uniform access to chemical data and tools experience gained in d...
PDF
API Basics
PDF
WordPress RESTful API & Amazon API Gateway (English version)
PDF
No REST for the Wicked: REST and Catalyst
PPTX
A Deep Dive into RESTful API Design Part 2
PPTX
Soap UI - Lesson3
PPTX
Rest Essentials
PPTX
RESTful for opentravel.org by HP
PPTX
RESTful design
PPTX
REST Api Tips and Tricks
PDF
Agile RESTful Web Development
PPTX
REST Methodologies
PDF
OpenTravel Advisory Forum 2012 REST XML Resources
PPTX
Http and REST APIs.
Getting to Grips with RESTful APIs
The Power of Open Data
Enter the app era with ruby on rails (rubyday)
RESTful modules in zf2
API management with Taffy and API Blueprint
Seamless and uniform access to chemical data and tools experience gained in d...
API Basics
WordPress RESTful API & Amazon API Gateway (English version)
No REST for the Wicked: REST and Catalyst
A Deep Dive into RESTful API Design Part 2
Soap UI - Lesson3
Rest Essentials
RESTful for opentravel.org by HP
RESTful design
REST Api Tips and Tricks
Agile RESTful Web Development
REST Methodologies
OpenTravel Advisory Forum 2012 REST XML Resources
Http and REST APIs.
Ad

More from Paul Shapiro (9)

PPTX
Rolling Your Own Rank Tracking Solution (Tech SEO Connect 2024)
PPTX
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro
PPTX
Redefining Technical SEO, #MozCon 2019 by Paul Shapiro
PPTX
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018
PPTX
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...
PPTX
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...
PPTX
Idea: Selling Clients Google+ Through YouTube
PPTX
Social-SEO Content Strategy: Ideas for a Data Driven Approach
PPTX
Regular Expressions for Regular Joes (and SEOs)
Rolling Your Own Rank Tracking Solution (Tech SEO Connect 2024)
Breaking Down NLP for SEOs - SMX Advanced Europe 2019 - Paul Shapiro
Redefining Technical SEO, #MozCon 2019 by Paul Shapiro
Start Building SEO Efficiencies with Automation - MNSearch Summit 2018
Put Your Data To Work: Ways to Uncover Content Ideas That Deliver #Confluence...
The Actionable Guide to Doing Better Semantic Keyword Research #BrightonSEO (...
Idea: Selling Clients Google+ Through YouTube
Social-SEO Content Strategy: Ideas for a Data Driven Approach
Regular Expressions for Regular Joes (and SEOs)

Recently uploaded (20)

PPTX
The evolution of the internet - its impacts on consumers
PDF
NeuroRank™: The Future of AI-First SEO..
PDF
AFCAT Syllabus 2026 Guide by Best Defence Academy in Lucknow.pdf
PDF
Future Retail Disruption Trends and Observations
PDF
MARG’s Door & Window Hardware Catalogue | Trending Branding Digital Solutions
PDF
Digital Marketing Agency in Thrissur with Proven Strategies for Local Growth
PDF
Prove and Prioritize Profitability in Every Marketing Campaign - Zach Sherrod...
PDF
UNIT 1 -3 Factors Influencing RURAL CONSUMER BEHAVIOUR.pdf
PDF
Is Kanav Kesar Legit or a Scam? Uncovering the Truth Behind the Hype
PDF
DIGITAL MARKETING STRATEGIST IN KASARAGOD
PPTX
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
PDF
PDF
AI & Automation: The Future of Marketing or the End of Creativity - Eric Ritt...
PDF
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
DOCX
AL-ahly Sabbour un official strategic plan.docx
PDF
EVOLUTION OF RURAL MARKETING IN INDIAN CIVILIZATION
PDF
UNIT 2 - 5 DISTRIBUTION IN RURAL MARKETS.pdf
PPTX
Kimberly Crossland Storytelling Marketing Class 5stars.pptx
PDF
How a Travel Company Can Implement Content Marketing
PDF
Ramjilal Ramsaroop || Trending Branding
The evolution of the internet - its impacts on consumers
NeuroRank™: The Future of AI-First SEO..
AFCAT Syllabus 2026 Guide by Best Defence Academy in Lucknow.pdf
Future Retail Disruption Trends and Observations
MARG’s Door & Window Hardware Catalogue | Trending Branding Digital Solutions
Digital Marketing Agency in Thrissur with Proven Strategies for Local Growth
Prove and Prioritize Profitability in Every Marketing Campaign - Zach Sherrod...
UNIT 1 -3 Factors Influencing RURAL CONSUMER BEHAVIOUR.pdf
Is Kanav Kesar Legit or a Scam? Uncovering the Truth Behind the Hype
DIGITAL MARKETING STRATEGIST IN KASARAGOD
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
AI & Automation: The Future of Marketing or the End of Creativity - Eric Ritt...
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
AL-ahly Sabbour un official strategic plan.docx
EVOLUTION OF RURAL MARKETING IN INDIAN CIVILIZATION
UNIT 2 - 5 DISTRIBUTION IN RURAL MARKETS.pdf
Kimberly Crossland Storytelling Marketing Class 5stars.pptx
How a Travel Company Can Implement Content Marketing
Ramjilal Ramsaroop || Trending Branding

How to Leverage APIs for SEO #TTTLive2019