Connect with us

MARKETING

The Moz Links API: An Introduction

Published

on

The Moz Links API: An Introduction

What exactly IS an API? They’re those things that you copy and paste long strange codes into Screaming Frog for links data on a Site Crawl, right?

I’m here to tell you there’s so much more to them than that – if you’re willing to take just a few little steps. But first, some basics.

What’s an API?

API stands for “application programming interface”, and it’s just the way of… using a thing. Everything has an API. The web is a giant API that takes URLs as input and returns pages.

But special data services like the Moz Links API have their own set of rules. These rules vary from service to service and can be a major stumbling block for people taking the next step.

When Screaming Frog gives you the extra links columns in a crawl, it’s using the Moz Links API, but you can have this capability anywhere. For example, all that tedious manual stuff you do in spreadsheet environments can be automated from data-pull to formatting and emailing a report.

If you take this next step, you can be more efficient than your competitors, designing and delivering your own SEO services instead of relying upon, paying for, and being limited by the next proprietary product integration.

GET vs. POST

Most APIs you’ll encounter use the same data transport mechanism as the web. That means there’s a URL involved just like a website. Don’t get scared! It’s easier than you think. In many ways, using an API is just like using a website.

As with loading web pages, the request may be in one of two places: the URL itself, or in the body of the request. The URL is called the “endpoint” and the often invisibly submitted extra part of the request is called the “payload” or “data”. When the data is in the URL, it’s called a “query string” and indicates the “GET” method is used. You see this all the time when you search:

https://www.google.com/search?q=moz+links+api <-- GET method 

When the data of the request is hidden, it’s called a “POST” request. You see this when you submit a form on the web and the submitted data does not show on the URL. When you hit the back button after such a POST, browsers usually warn you against double-submits. The reason the POST method is often used is that you can fit a lot more in the request using the POST method than the GET method. URLs would get very long otherwise. The Moz Links API uses the POST method.

Making requests

A web browser is what traditionally makes requests of websites for web pages. The browser is a type of software known as a client. Clients are what make requests of services. More than just browsers can make requests. The ability to make client web requests is often built into programming languages like Python, or can be broken out as a standalone tool. The most popular tools for making requests outside a browser are curl and wget.

We are discussing Python here. Python has a built-in library called URLLIB, but it’s designed to handle so many different types of requests that it’s a bit of a pain to use. There are other libraries that are more specialized for making requests of APIs. The most popular for Python is called requests. It’s so popular that it’s used for almost every Python API tutorial you’ll find on the web. So I will use it too. This is what “hitting” the Moz Links API looks like:

response = requests.post(endpoint, data=json_string, auth=auth_tuple)

Given that everything was set up correctly (more on that soon), this will produce the following output:

{'next_token': 'JYkQVg4s9ak8iRBWDiz1qTyguYswnj035nqrQ1oIbW96IGJsb2dZgGzDeAM7Rw==',
 'results': [{'anchor_text': 'moz',
              'external_pages': 7162,
              'external_root_domains': 2026}]}

This is JSON data. It’s contained within the response object that was returned from the API. It’s not on the drive or in a file. It’s in memory. So long as it’s in memory, you can do stuff with it (often just saving it to a file).

If you wanted to grab a piece of data within such a response, you could refer to it like this:

response['results'][0]['external_pages']

This says: “Give me the first item in the results list, and then give me the external_pages value from that item.” The result would be 7162.

NOTE: If you’re actually following along executing code, the above line won’t work alone. There’s a certain amount of setup we’ll do shortly, including installing the requests library and setting up a few variables. But this is the basic idea.

JSON

JSON stands for JavaScript Object Notation. It’s a way of representing data in a way that’s easy for humans to read and write. It’s also easy for computers to read and write. It’s a very common data format for APIs that has somewhat taken over the world since the older ways were too difficult for most people to use. Some people might call this part of the “restful” API movement, but the much more difficult XML format is also considered “restful” and everyone seems to have their own interpretation. Consequently, I find it best to just focus on JSON and how it gets in and out of Python.

Python dictionaries

I lied to you. I said that the data structure you were looking at above was JSON. Technically it’s really a Python dictionary or dict datatype object. It’s a special kind of object in Python that’s designed to hold key/value pairs. The keys are strings and the values can be any type of object. The keys are like the column names in a spreadsheet. The values are like the cells in the spreadsheet. In this way, you can think of a Python dict as a JSON object. For example here’s creating a dict in Python:

my_dict = {
    "name": "Mike",
    "age": 52,
    "city": "New York"
}

And here is the equivalent in JavaScript:

var my_json = {
    "name": "Mike",
    "age": 52,
    "city": "New York"
}

Pretty much the same thing, right? Look closely. Key-names and string values get double-quotes. Numbers don’t. These rules apply consistently between JSON and Python dicts. So as you might imagine, it’s easy for JSON data to flow in and out of Python. This is a great gift that has made modern API-work highly accessible to the beginner through a tool that has revolutionized the field of data science and is making inroads into marketing, Jupyter Notebooks.

Flattening data

But beware! As data flows between systems, it’s not uncommon for the data to subtly change. For example, the JSON data above might be converted to a string. Strings might look exactly like JSON, but they’re not. They’re just a bunch of characters. Sometimes you’ll hear it called “serializing”, or “flattening”. It’s a subtle point, but worth understanding as it will help with one of the largest stumbling blocks with the Moz Links (and most JSON) APIs.

Objects have APIs

Actual JSON or dict objects have their own little APIs for accessing the data inside of them. The ability to use these JSON and dict APIs goes away when the data is flattened into a string, but it will travel between systems more easily, and when it arrives at the other end, it will be “deserialized” and the API will come back on the other system.

Data flowing between systems

This is the concept of portable, interoperable data. Back when it was called Electronic Data Interchange (or EDI), it was a very big deal. Then along came the web and then XML and then JSON and now it’s just a normal part of doing business.

If you’re in Python and you want to convert a dict to a flattened JSON string, you do the following:

import json

my_dict = {
    "name": "Mike",
    "age": 52,
    "city": "New York"
}

json_string = json.dumps(my_dict)

…which would produce the following output:

'{"name": "Mike", "age": 52, "city": "New York"}'

This looks almost the same as the original dict, but if you look closely you can see that single-quotes are used around the entire thing. Another obvious difference is that you can line-wrap real structured data for readability without any ill effect. You can’t do it so easily with strings. That’s why it’s presented all on one line in the above snippet.

Such stringifying processes are done when passing data between different systems because they are not always compatible. Normal text strings on the other hand are compatible with almost everything and can be passed on web-requests with ease. Such flattened strings of JSON data are frequently referred to as the request.

Anatomy of a request

Again, here’s the example request we made above:

response = requests.post(endpoint, data=json_string, auth=auth_tuple)

Now that you understand what the variable name json_string is telling you about its contents, you shouldn’t be surprised to see this is how we populate that variable:

 data_dict = {
    "target": "moz.com/blog",
    "scope": "page",
    "limit": 1
}

json_string = json.dumps(data_dict)

…and the contents of json_string looks like this:

'{"target": "moz.com/blog", "scope": "page", "limit": 1}'

This is one of my key discoveries in learning the Moz Links API. This is in common with countless other APIs out there but trips me up every time because it’s so much more convenient to work with structured dicts than flattened strings. However, most APIs expect the data to be a string for portability between systems, so we have to convert it at the last moment before the actual API-call occurs.

Pythonic loads and dumps

Now you may be wondering in that above example, what a dump is doing in the middle of the code. The json.dumps() function is called a “dumper” because it takes a Python object and dumps it into a string. The json.loads() function is called a “loader” because it takes a string and loads it into a Python object.

The reason for what appear to be singular and plural options are actually binary and string options. If your data is binary, you use json.load() and json.dump(). If your data is a string, you use json.loads() and json.dumps(). The s stands for string. Leaving the s off means binary.

Don’t let anybody tell you Python is perfect. It’s just that its rough edges are not excessively objectionable.

Assignment vs. equality

For those of you completely new to Python or programming in general, what we’re doing when we hit the API is called an assignment. The result of requests.post() is being assigned to the variable named response.

response = requests.post(endpoint, data=json_string, auth=auth_tuple)

We are using the = sign to assign the value of the right side of the equation to the variable on the left side of the equation. The variable response is now a reference to the object that was returned from the API. Assignment is different from equality. The == sign is used for equality.

# This is assignment:
a = 1  # a is now equal to 1

# This is equality:
a == 1  # True, but relies that the above line has been executed

The POST method

response = requests.post(endpoint, data=json_string, auth=auth_tuple)

The requests library has a function called post() that takes 3 arguments. The first argument is the URL of the endpoint. The second argument is the data to send to the endpoint. The third argument is the authentication information to send to the endpoint.

Keyword parameters and their arguments

You may notice that some of the arguments to the post() function have names. Names are set equal to values using the = sign. Here’s how Python functions get defined. The first argument is positional both because it comes first and also because there’s no keyword. Keyworded arguments come after position-dependent arguments. Trust me, it all makes sense after a while. We all start to think like Guido van Rossum.

def arbitrary_function(argument1, name=argument2):
    # do stuff

The name in the above example is called a “keyword” and the values that come in on those locations are called “arguments”. Now arguments are assigned to variable names right in the function definition, so you can refer to either argument1 or argument2 anywhere inside this function. If you’d like to learn more about the rules of Python functions, you can read about them here.

Setting up the request

Okay, so let’s let you do everything necessary for that success assured moment. We’ve been showing the basic request:

response = requests.post(endpoint, data=json_string, auth=auth_tuple)

…but we haven’t shown everything that goes into it. Let’s do that now. If you’re following along and don’t have the requests library installed, you can do so with the following command from the same terminal environment from which you run Python:

pip install requests

Often times Jupyter will have the requests library installed already, but in case it doesn’t, you can install it with the following command from inside a Notebook cell:

!pip install requests

And now we can put it all together. There’s only a few things here that are new. The most important is how we’re taking 2 different variables and combining them into a single variable called AUTH_TUPLE. You will have to get your own ACCESSID and SECRETKEY from the Moz.com website.

The API expects these two values to be passed as a Python data structure called a tuple. A tuple is a list of values that don’t change. I find it interesting that requests.post() expects flattened strings for the data parameter, but expects a tuple for the auth parameter. I suppose it makes sense, but these are the subtle things to understand when working with APIs.

Here’s the full code:

import json
import pprint
import requests

# Set Constants
ACCESSID = "mozscape-1234567890"  # Replace with your access ID
SECRETKEY = "1234567890abcdef1234567890abcdef"  # Replace with your secret key
AUTH_TUPLE = (ACCESSID, SECRETKEY)

# Set Variables
endpoint = "https://lsapi.seomoz.com/v2/anchor_text"
data_dict = {"target": "moz.com/blog", "scope": "page", "limit": 1}
json_string = json.dumps(data_dict)

# Make the Request
response = requests.post(endpoint, data=json_string, auth=AUTH_TUPLE)

# Print the Response
pprint(response.json())

…which outputs:

{'next_token': 'JYkQVg4s9ak8iRBWDiz1qTyguYswnj035nqrQ1oIbW96IGJsb2dZgGzDeAM7Rw==',
 'results': [{'anchor_text': 'moz',
              'external_pages': 7162,
              'external_root_domains': 2026}]}

Using all upper case for the AUTH_TUPLE variable is a convention many use in Python to indicate that the variable is a constant. It’s not a requirement, but it’s a good idea to follow conventions when you can.

You may notice that I didn’t use all uppercase for the endpoint variable. That’s because the anchor_text endpoint is not a constant. There are a number of different endpoints that can take its place depending on what sort of lookup we wanted to do. The choices are:

  1. anchor_text

  2. final_redirect

  3. global_top_pages

  4. global_top_root_domains

  5. index_metadata

  6. link_intersect

  7. link_status

  8. linking_root_domains

  9. links

  10. top_pages

  11. url_metrics

  12. usage_data

And that leads into the Jupyter Notebook that I prepared on this topic located here on Github. With this Notebook you can extend the example I gave here to any of the 12 available endpoints to create a variety of useful deliverables, which will be the subject of articles to follow.

Source link

Keep an eye on what we are doing
Be the first to get latest updates and exclusive content straight to your email inbox.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

MARKETING

18 Events and Conferences for Black Entrepreneurs in 2024

Published

on

18 Events and Conferences for Black Entrepreneurs in 2024

Welcome to Breaking the Blueprint — a blog series that dives into the unique business challenges and opportunities of underrepresented business owners and entrepreneurs. Learn how they’ve grown or scaled their businesses, explored entrepreneurial ventures within their companies, or created side hustles, and how their stories can inspire and inform your own success.

It can feel isolating if you’re the only one in the room who looks like you.

(more…)

Keep an eye on what we are doing
Be the first to get latest updates and exclusive content straight to your email inbox.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
Continue Reading

MARKETING

IAB Podcast Upfront highlights rebounding audiences and increased innovation

Published

on

IAB podcast upfronts in New York

IAB podcast upfronts in New York
Left to right: Hosts Charlamagne tha God and Jess Hilarious, Will Pearson, President, iHeartPodcasts and Conal Byrne, CEO, iHeartMedia Digital Group in New York. Image: Chris Wood.

Podcasts are bouncing back from last year’s slowdown with digital audio publishers, tech partners and brands innovating to build deep relationships with listeners.

At the IAB Podcast Upfront in New York this week, hit shows and successful brand placements were lauded. In addition to the excitement generated by stars like Jon Stewart and Charlamagne tha God, the numbers gauging the industry also showed promise.

U.S. podcast revenue is expected to grow 12% to reach $2 billion — up from 5% growth last year — according to a new IAB/PwC study. Podcasts are projected to reach $2.6 billion by 2026.

The growth is fueled by engaging content and the ability to measure its impact. Adtech is stepping in to measure, prove return on spend and manage brand safety in gripping, sometimes contentious, environments.

“As audio continues to evolve and gain traction, you can expect to hear new innovations around data, measurement, attribution and, crucially, about the ability to assess podcasting’s contribution to KPIs in comparison to other channels in the media mix,” said IAB CEO David Cohen, in his opening remarks.

Comedy and sports leading the way

Podcasting’s slowed growth in 2023 was indicative of lower ad budgets overall as advertisers braced for economic headwinds, according to Matt Shapo, director, Media Center for IAB, in his keynote. The drought is largely over. Data from media analytics firm Guideline found podcast gross media spend up 21.7% in Q1 2024 over Q1 2023. Monthly U.S. podcast listeners now number 135 million, averaging 8.3 podcast episodes per week, according to Edison Research.

Comedy overtook sports and news to become the top podcast category, according to the new IAB report, “U.S. Podcast Advertising Revenue Study: 2023 Revenue & 2024-2026 Growth Projects.” Comedy podcasts gained nearly 300 new advertisers in Q4 2023.

Sports defended second place among popular genres in the report. Announcements from the stage largely followed these preferences.

Jon Stewart, who recently returned to “The Daily Show” to host Mondays, announced a new podcast, “The Weekly Show with Jon Stewart,” via video message at the Upfront. The podcast will start next month and is part of Paramount Audio’s roster, which has a strong sports lineup thanks to its association with CBS Sports.

Reaching underserved groups and tastes

IHeartMedia toasted its partnership with radio and TV host Charlamagne tha God. Charlamagne’s The Black Effect is the largest podcast network in the U.S. for and by black creators. Comedian Jess Hilarious spoke about becoming the newest co-host of the long-running “The Breakfast Club” earlier this year, and doing it while pregnant.

The company also announced a new partnership with Hello Sunshine, a media company founded by Oscar-winner Reese Witherspoon. One resulting podcast, “The Bright Side,” is hosted by journalists Danielle Robay and Simone Boyce. The inspiration for the show was to tell positive stories as a counterweight to negativity in the culture.

With such a large population listening to podcasts, advertisers can now benefit from reaching specific groups catered to by fine-tuned creators and topics. As the top U.S. audio network, iHeartMedia touted its reach of 276 million broadcast listeners. 

Connecting advertisers with the right audience

Through its acquisition of technology, including audio adtech company Triton Digital in 2021, as well as data partnerships, iHeartMedia claims a targetable audience of 34 million podcast listeners through its podcast network, and a broader audio audience of 226 million for advertisers, using first- and third-party data.

“A more diverse audience is tuning in, creating more opportunities for more genres to reach consumers — from true crime to business to history to science and culture, there is content for everyone,” Cohen said.

The IAB study found that the top individual advertiser categories in 2023 were Arts, Entertainment and Media (14%), Financial Services (13%), CPG (12%) and Retail (11%). The largest segment of advertisers was Other (27%), which means many podcast advertisers have distinct products and services and are looking to connect with similarly personalized content.

Acast, the top global podcast network, founded in Stockholm a decade ago, boasts 125,000 shows and 400 million monthly listeners. The company acquired podcast database Podchaser in 2022 to gain insights on 4.5 million podcasts (at the time) with over 1.7 billion data points.

Measurement and brand safety

Technology is catching up to the sheer volume of content in the digital audio space. Measurement company Adelaide developed its standard unit of attention, the AU, to predict how effective ad placements will be in an “apples to apples” way across channels. This method is used by The Coca-Cola Company, NBA and AB InBev, among other big advertisers.

In a study with National Public Media, which includes NPR radio and popular podcasts like the “Tiny Desk” concert series, Adelaide found that NPR, on average, scored 10% higher than Adelaide’s Podcast AU Benchmarks, correlating to full-funnel outcomes. NPR listeners weren’t just clicking through to advertisers’ sites, they were considering making a purchase.

Advertisers can also get deep insights on ad effectiveness through Wondery’s premium podcasts — the company was acquired by Amazon in 2020. Ads on its podcasts can now be managed through the Amazon DSP, and measurement of purchases resulting from ads will soon be available.

The podcast landscape is growing rapidly, and advertisers are understandably concerned about involving their brands with potentially controversial content. AI company Seekr develops large language models (LLMs) to analyze online content, including the context around what’s being said on a podcast. It offers a civility rating that determines if a podcast mentioning “shootings,” for instance, is speaking responsibly and civilly about the topic. In doing so, Seekr adds a layer of confidence for advertisers who would otherwise pass over an opportunity to reach an engaged audience on a topic that means a lot to them. Seekr recently partnered with ad agency Oxford Road to bring more confidence to clients.

“When we move beyond the top 100 podcasts, it becomes infinitely more challenging for these long tails of podcasts to be discovered and monetized,” said Pat LaCroix, EVP, strategic partnerships at Seekr. “Media has a trust problem. We’re living in a time of content fragmentation, political polarization and misinformation. This is all leading to a complex and challenging environment for brands to navigate, especially in a channel where brand safety tools have been in the infancy stage.”



Dig deeper: 10 top marketing podcasts for 2024

Source link

Keep an eye on what we are doing
Be the first to get latest updates and exclusive content straight to your email inbox.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
Continue Reading

MARKETING

Foundations of Agency Success: Simplifying Operations for Growth

Published

on

Foundations of Agency Success: Simplifying Operations for Growth

Foundations of Agency Success Simplifying Operations for Growth

Why do we read books like Traction, Scaling Up, and the E-Myth and still struggle with implementing systems, defining processes, and training people in our agency?

Those are incredibly comprehensive methodologies. And yet digital agencies still suffer from feast or famine months, inconsistent results and timelines on projects, quality control, revisions, and much more. It’s not because they aren’t excellent at what they do. I

t’s not because there isn’t value in their service. It’s often because they haven’t defined the three most important elements of delivery: the how, the when, and the why

Complicating our operations early on can lead to a ton of failure in implementing them. Business owners overcomplicate their own processes, hesitate to write things down, and then there’s a ton of operational drag in the company.

Couple that with split attention and paper-thin resources and you have yourself an agency that spends most of its time putting out fires, reacting to problems with clients, and generally building a culture of “the Founder/Creative Director/Leader will fix it” mentality. 

Before we chat through how truly simple this can all be, let’s first go back to the beginning. 

When we start our companies, we’re told to hustle. And hustle hard. We’re coached that it takes a ton of effort to create momentum, close deals, hire people, and manage projects. And that is all true. There is a ton of work that goes into getting a business up and running.

1715505963 461 Foundations of Agency Success Simplifying Operations for Growth1715505963 461 Foundations of Agency Success Simplifying Operations for Growth

The challenge is that we all adopt this habit of burning the candle at both ends and the middle all for the sake of growing the business. And we bring that habit into the next stage of growth when our business needs… you guessed it… exactly the opposite. 

In Mike Michalowitz’s book, Profit First he opens by insisting the reader understand and accept a fundamental truth: our business is a cash-eating monster. The truth is, our business is also a time-eating monster. And it’s only when we realize that as long as we keep feeding it our time and our resources, it’ll gobble everything up leaving you with nothing in your pocket and a ton of confusion around why you can’t grow.

Truth is, financial problems are easy compared to operational problems. Money is everywhere. You can go get a loan or go create more revenue by providing value easily. What’s harder is taking that money and creating systems that produce profitably. Next level is taking that money, creating profit and time freedom. 

In my bestselling book, The Sabbatical Method, I teach owners how to fundamentally peel back the time they spend in their company, doing everything, and how it can save owners a lot of money, time, and headaches by professionalizing their operations.

The tough part about being a digital agency owner is that you likely started your business because you were great at something. Building websites, creating Search Engine Optimization strategies, or running paid media campaigns. And then you ended up running a company. Those are two very different things. 

1715505964 335 Foundations of Agency Success Simplifying Operations for Growth1715505964 335 Foundations of Agency Success Simplifying Operations for Growth

How to Get Out of Your Own Way and Create Some Simple Structure for Your Agency…

  1. Start Working Less 

I know this sounds really brash and counterintuitive, but I’ve seen it work wonders for clients and colleagues alike. I often say you can’t see the label from inside the bottle and I’ve found no truer statement when it comes to things like planning, vision, direction, and operations creation.

Owners who stay in the weeds of their business while trying to build the structure are like hunters in the jungle hacking through the brush with a machete, getting nowhere with really sore arms. Instead, define your work day, create those boundaries of involvement, stop working weekends, nights and jumping over people’s heads to solve problems.

It’ll help you get another vantage point on  your company and your team can build some autonomy in the meantime. 

  1. Master the Art of Knowledge Transfer

There are two ways to impart knowledge on others: apprenticeship and writing something down. Apprenticeship began as a lifelong relationship and often knowledge was only retained by ONE person who would carry on your method.

Writing things down used to be limited  (before the printing press) to whoever held the pages.

We’re fortunate that today, we have many ways of imparting knowledge to our team. And creating this habit early on can save a business from being dependent on any one person who has a bunch of “how” and “when” up in their noggin.

While you’re taking some time to get out of the day-to-day, start writing things down and recording your screen (use a tool like loom.com) while you’re answering questions.

1715505964 938 Foundations of Agency Success Simplifying Operations for Growth1715505964 938 Foundations of Agency Success Simplifying Operations for Growth

Deposit those teachings into a company knowledge base, a central location for company resources. Some of the most scaleable and sellable companies I’ve ever worked with had this habit down pat. 

  1. Define Your Processes

Lean in. No fancy tool or software is going to save your company. Every team I’ve ever worked with who came to me with a half-built project management tool suffered immensely from not first defining their process. This isn’t easy to do, but it can be simple.

The thing that hangs up most teams to dry is simply making decisions. If you can decide how you do something, when you do it and why it’s happening that way, you’ve already won. I know exactly what you’re thinking: our process changes all the time, per client, per engagement, etc. That’s fine.

Small businesses should be finding better, more efficient ways to do things all the time. Developing your processes and creating a maintenance effort to keep them accurate and updated is going to be a liferaft in choppy seas. You’ll be able to cling to it when the agency gets busy. 

“I’m so busy, how can I possibly work less and make time for this?”

1715505964 593 Foundations of Agency Success Simplifying Operations for Growth1715505964 593 Foundations of Agency Success Simplifying Operations for Growth

You can’t afford not to do this work. Burning the candle at both ends and the middle will catch up eventually and in some form or another. Whether it’s burnout, clients churning out of the company, a team member leaving, some huge, unexpected tax bill.

I’ve heard all the stories and they all suck. It’s easier than ever to start a business and it’s harder than ever to keep one. This work might not be sexy, but it gives us the freedom we craved when we began our companies. 

Start small and simple and watch your company become more predictable and your team more efficient.


Disruptive Design Raising the Bar of Content Marketing with Graphic

Source link

Keep an eye on what we are doing
Be the first to get latest updates and exclusive content straight to your email inbox.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
Continue Reading

Trending