rah_downloader: Universal downloading helper function for Ahrefs API

Description Usage Arguments Details Value Source Examples

View source: R/downloader.R

Description

This is a helper function and it should not be used in most cases. Use rah_<report_name>() functions instead as they are specific wrappers that provide full documentation needed for each report.

Usage

1
2
3
rah_downloader(target, report, token = Sys.getenv("AHREFS_AUTH_TOKEN"),
  mode = "domain", metrics = NULL, limit = 1000, order_by = NULL,
  where = NULL, having = NULL)

Arguments

target

character string. Aim of a request: a domain, a directory or a URL

report

character string. Name of the table (report) to select data from

token

character string. Authentication token. Should be available through enviromental variables after authentication with function rah_auth()

mode

character string. Mode of operation: exact, domain, subdomains or prefix. See more in Details section

metrics

character vector of columns to select

limit

integer. Number of results to return

order_by

character vector of columns to sort on. See more in Details section

where

character string - a condition created by rah_condition_set function that generates proper "Where" condition to satisfy. See more in Details section

having

character string - a condition created by rah_condition_set function that generates proper "Having" condition to satisfy. See more in Details section

Details

1. "mode" parameter can take 4 different values that will affect how the results will be grouped.

Example of URL directory with folder:

Example of URL directory with subdomain:

2. "order_by" parameter is a character string that forces sorting of the results. Structure:

3. "where" & "having" are EXPERIMENTAL parameters of condition sets (character strings) that control filtering the results. To create arguments:

  1. use rah_condition() function to create a single condition, for example: cond_1 <- rah_condition(column_name = "links", operator = "GREATER_THAN", value = "10")

  2. use rah_condition_set() function to group single conditions into final condition string, for example: fin_cond <- rah_condition_set(cond_1, cond_2)

  3. provide final condition to proper report function as a parameter, for example: RAhrefs::rah_downloader(target = "ahrefs.com", token = "0123456789", mode = "domain", metrics = NULL, limit = 1000, where = fin_cond, order_by = "first_seen:asc")

Value

list or nested list object

Source

https://ahrefs.com/api/documentation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# do not use this function - instead use its wrappers (rah_<report_name>())
# that have full documentation
## Not run: RAhrefs::rah_downloader(
   target  = "ahrefs.com",
   report  = "anchors",
   token   = "0123456789",
   mode    = "domain",
   metrics = NULL,
   limit   = 1000,
   where   = rah_condition_set(
     rah_condition(column_name = "links",
                   operator = "GREATER_THAN",
                   value = "10"),
     rah_condition(column_name = "links",
                   operator = "LESS_THAN",
                   value = "20")),
   order_by = "first_seen:asc")
## End(Not run)

RAhrefs documentation built on July 28, 2019, 9:03 a.m.