Description Usage Arguments Details References Examples
Article search
1 2 3 4 |
q |
Search query term. Search is performed on the article body, headline and byline. |
fq |
Filtered search query using standard Lucene syntax. The filter
query can be specified with or without a limiting field: label. See
|
sort |
(character) Default NULL. One of newest or oldest . By default, search results are sorted by their relevance to the query term (q). Use the sort parameter to sort by pub_date. |
begin_date |
Begin date - Restricts responses to results with publication dates of the date specified or later. In the form YYYYMMDD |
end_date |
End date - Restricts responses to results with publication dates of the date specified or earlier. In the form YYYYMMDD |
key |
your New York Times API key; pass in, or loads from .Renviron as
|
fl |
(character) Vector of fields to return. default: all fields |
hl |
(logical) Highlight or not, default: |
page |
Page number. The value of page corresponds to a set of 10 results (it does not indicate the starting number of the result set). For example, page=0 corresponds to records 0-9. To return records 10-19, set page to 1, not 10. |
all_results |
(logical) return all results. Default: |
try_flatten |
(logical) attempt to completely flatten data.frame,
which may fail in some cases as its hard to account for all edge cases.
Default: |
facet_field |
(character) Specifies the sets of facet values to include in the facets array at the end of response, which collects the facet values from all the search results. By default no facet fields will be returned. See Details for options. |
facet_filter |
(logical) Fields to facet on, as vector. When set to
|
sleep |
(integer) seconds to sleep between successive requests, only
used when |
... |
Futher args pass into query |
callopts |
Curl options (debugging tools mostly) passed to
|
fl
parameter options are:
web_url
snippet
lead_paragraph
abstract
print_page
blog
source
multimedia
headline
keywords
pub_date
document_type
news_desk
byline
type_of_material
_id
word_count
facet_field
param options are:
section_name
document_type
type_of_material
source
day_of_week
http://developer.nytimes.com, https://developer.nytimes.com/docs/articlesearch-product/1/overview
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 28 29 30 31 32 33 34 35 36 37 | ## Not run:
# basic search - copyright, metadata, data, and facet slots
(x <- as_search(q="bailout", begin_date = "20081001",
end_date = '20081005', callopts = list(verbose = TRUE)))
x$copyright
x$meta
x$data
x$facet
Sys.sleep(1)
as_search(q="money", fq = 'The New York Times', fl = c('word_count',
'snippet', 'headline'))
Sys.sleep(1)
x <- as_search(q="bailout", hl = TRUE)
x$data$snippet
Sys.sleep(1)
# all results
(x <- as_search(q="bailout", begin_date = "20081001",
end_date = '20081003', all_results = TRUE))
x$meta
x$data
Sys.sleep(1)
# facetting
as_search(q="bailout", facet_field = 'section_name', begin_date = "20081001",
end_date = '20081201')
Sys.sleep(1)
## with facet filtering
as_search(q="bailout", facet_field = 'section_name', begin_date = "20081001",
end_date = '20081201', facet_filter = TRUE)
# curl options
x <- as_search(q="bailout", begin_date = "20081001",
end_date = '20081005', callopts = list(verbose = TRUE))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.