url_reports: Request SEMRush URL Reports

Description Usage Arguments Value Examples

View source: R/url_reports.R

Description

This function creates a request to the SEMRush SEO database for users with a subscription and sufficient API units. See the SEMRush API website (https://www.semrush.com/api-analytics/) for additional information, including a list of codes for the regional databases and export variables.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
url_reports(
  type,
  key,
  url,
  database,
  display_limit = 5,
  display_offset,
  display_date,
  export_columns,
  return_url = FALSE
)

Arguments

type

string. REQUIRED. The report type to be generated. Available report types are 'url_organic' or 'url_adwords'.

key

string. REQUIRED. An identification key assigned to a user after subscribing to SEMrush. The key is available on the Profile page.

url

string. REQUIRED. The URL of a landing page you would like to investigate (example: https://cran.r-project.org/).

database

string. REQUIRED. A regional database. If this parameter is not specified (i.e., ""), your request will be sent to all regional databases.

display_limit

integer. The number of results returned to a request. If this parameter is set to 0, up to 10,000 lines will be returned. Default is 5 lines.

display_offset

integer. This parameter allows you to skip a specified number of results before sending a report. Please keep in mind that if you use the option display_offset, display_limit, the value should be increased by value display_offset.

display_date

string. Date in format "YYYYMM15". A date on which a report will be shown. You can roll back to the past or choose an actual date.

export_columns

vector. A vector of character strings specifying the variables to be included in the report, which vary according to the report type (see 'type' argument). If this parameter is not specified, default columns will be sent.

return_url

logical. If TRUE, prints the request URL used to generate the report. Default value is FALSE.

Value

A data table (tibble) with columns for each requested variable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
#Enter your SEMRush account API key.
#'key <- ""

## Get 'url_organic' report
urlToInvestigate <- "https://cran.r-project.org/"
#request report
report <- url_reports(
    type = "url_organic",
    key = key,
    url = urlToInvestigate,
    database = "us",
    display_limit = 5,
    export_columns = c("Ph", "Po", "Pp", "Nq", "Cp")
)

print(report)
# A tibble: 5 x 5
 Keyword                    Position Previous.Position Search.Volume   CPC
 <chr>                         <int>             <int>         <int> <dbl>
1 cran                              1                 1          8100  1.42
2 r cran                            1                 1          5400  0   
3 r cran download                   1                 1           590  0   
4 cran r project org windows        1                 1           590  0   
5 cran r project                    1                 1           480  0

## End(Not run) 

ericvc/semRush documentation built on Aug. 7, 2020, 12:54 p.m.