seo-api
v1.2.1
Published
A client package for accessing the Hooray SEO API
Downloads
9
Readme
SEO-API
The Hooray SEO API, accompanied by a client-side JavaScript package to interact with the API. This was developed by Jake Labate for the purposes of accelerating the auditing, fulfillment and reporting of the agency's SEO services.
Install & Import
npm i seo-api
import SEO from 'seo-api';
Init & Auth
auth
(required)
- Email Jake at [email protected] to request an access token.
brand_id
(optional)
- This accesses previous saved information about a brand you wish to consider when calling services.
const seo = new SEO({
auth: process.env.SEO_API_KEY,
brand_id: 'your-brand-id'
});
Service Configuration
- The
config
object specifies input information for the requested service. - The 2 keys in the
config
object arestyle
anddata
.
const seo = new SEO({
auth: process.env.SEO_API_KEY,
brand_id: 'your-brand-id'
});
const config = {
style: '',
data: []
}
seo.audit.speed(config);
style
- The
style
key sets the style / format / option / desired approach of the requested service. - Defaults to a service-specific
default
style if not set. - Style options depend on the requested service.
data
- The
data
key expects information used in the services requested. This expects an array of objects to perform the service on. - Multi-object requests are server-processed in parallel, and await all responses before returning.
- The expect keys nested inside a
data
object change based on the service requested.
// config.data as an array of objects
seo.generate.titleTag({
style: 'pathIndicative',
data: [
{ url: 'https://www.jakelabate.com/clients/hooray-agency' },
{ url: 'https://www.jakelabate.com/work/hotel-schema' }
]
});
Object-specific styling
style
keys can be placed inside each data
object for more granular styling options. Falls back to the config.style
key value.
seo.generate.titleTag({
style: 'pathIndicative', // fallback styling
data: [
{
style: 'ai', // processed as 'ai'
url: 'https://www.jakelabate.com/clients/hooray-agency'
},
{
style: null, // processed as 'pathIndicative'
url: 'https://www.jakelabate.com/clients/bitx-funding'
}
]
});
Response Object
{
status: 'success',
code: 200,
value: [], // returns a res object for each req object
errors: [], // if any server errors
meta: {
timestamp: 1620000000,
service: 'generate/title-tag', // endpoint path
docs: 'https://www.npmjs.com/package/seo-api#{{service}}' // public README.md
}
}
Service Index
Data Gathering Services
// function path
seo.gather
User Data
seo.gather.userData({
style: '',
data: [
]
});
Auditing Services
// function path
seo.audit
Domain Age
seo.audit.domainAge({
style: '',
data: [
]
});
Forms
seo.audit.forms({
style: '',
data: [
]
});
Heading Structure
seo.audit.headingStructure({
style: '',
data: [
]
});
Images
seo.audit.images({
style: '',
data: [
]
});
Links
seo.audit.links({
style: '',
data: [
]
});
Meta Data
seo.audit.metaData({
style: '',
data: [
]
});
Robots txt
seo.audit.robotTxt({
style: '',
data: [
]
});
Schema Markup
seo.audit.schemaMarkup({
style: '',
data: [
]
});
Sitemap
seo.audit.sitemap({
style: '',
data: [
]
});
Speed
seo.audit.speed({
style: '',
data: [
]
});
SSL Certificate
seo.audit.sslCertificate({
style: '',
data: [
]
});
URL Structure
seo.audit.urlStructure({
style: '',
data: [
]
});
Compression Services
// function path
seo.compress
Image
Compress the file size of any publicly accessible image (via a URL) without losing image quality.
Config
style
- Not relevant for this service.
data
image_url
is the URL of the publicly accessible image.
seo.compress.image({
style: null,
data: [
{
image_url: 'https://www.example.com/image.png'
}
]
});
Generation Services
// function path
seo.generate
Title Tag
Write a title tag for any published or non-published URL.
seo.generate.titleTag({
style: '',
data: [
]
});
Meta Description
Write a meta description for any published URL.
seo.generate.metaDescription({
style: '',
data: [
]
});
Image Alt Text
Generate alt text for any publicly accessible image (via a URL).
seo.generate.imageAltText({
style: '',
data: [
]
});
Open Graph Image
seo.generate.openGraphImage({
style: '',
data: [
]
});
Reporting Services
// function path
seo.report
The report
service is a single-endpoint service that works a little different.
style
- The
pdf
option returns a PDF report.
data
- Expects an array of service-result objects in the default service-returned response.
async function reportWebsiteSpeed(url) {
const response = await seo.audit.speed({
style: null,
data: [{ url }]
});
return await seo.report({
style: 'pdf',
data: response
});
}
const url = 'https://www.jakelabate.com';
reportWebsiteSpeed(url);