Title: | Client Library for The Guardian |
---|---|
Description: | A client library for 'The Guardian' (https://www.guardian.com/) and their API, this package allows users to search for Guardian articles and retrieve both the content and metadata. |
Authors: | Oliver Keyes |
Maintainer: | Oliver Keyes <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-22 04:06:09 UTC |
Source: | https://github.com/ironholds/rdian |
guardian_and
and guardian_or
provide
(respectively) the AND and OR logical operators. If you pass them your
query terms, it passes them back either separated (so that the Guardian API
knows to consider a match to any one term a match) or grouped (so that
the API only matches if every term appears).
guardian_and(...) guardian_or(...)
guardian_and(...) guardian_or(...)
... |
a vector of terms (or several vector of terms) |
a single string containing the terms, separated by the AND (,) or OR (|) separators used by the Guardian API.
# Simple AND example guardian_and("sausage", "mash") # With ORs guardian_or("sausage", "mash")
# Simple AND example guardian_and("sausage", "mash") # With ORs guardian_or("sausage", "mash")
guardian_content
lets you directly search
The Guardian for content, including support for conditional
searches, date-range based filtering, and section or tag
based filtering.
guardian_content(api_key, query, from = NULL, to = NULL, section = NULL, reference = NULL, reference_type = NULL, tags = NULL, rights = NULL, ids = NULL, production_office = NULL, page = NULL, page_size = 50, fields = NULL, collapse = TRUE, ...)
guardian_content(api_key, query, from = NULL, to = NULL, section = NULL, reference = NULL, reference_type = NULL, tags = NULL, rights = NULL, ids = NULL, production_office = NULL, page = NULL, page_size = 50, fields = NULL, collapse = TRUE, ...)
api_key |
A key to the Guardian API, which can be obtained here. |
query |
Your search query. This can contain operators ( |
from |
the date to limit by. If set, the search will only cover data written after this date.
Optional (NULL) by default. Can be set in conjunction with |
to |
Another date to limit by. If set, the search will only cover data written before this date.
Optional (NULL) by default. Can be set in conjunction with |
section |
the section, or sections, of The Guardian that you want to limit the search to. Multiple
sections may be concatenated together using boolean operators; see |
reference |
the references to limit the search to; only articles that include those references (and meet other conditions) will be returned. Also accepts boolean operators. |
reference_type |
the type of reference (such as |
tags |
the tags to limit the search to; only articles that contain these tags will be returned. Also accepts boolean operators. |
rights |
limit a search to content with these rights (syndicatable content, for example). Options are
|
ids |
limit a search to content with these IDs, an ID being the standard URL fragment after |
production_office |
the production office(s) to limit to, such as "aus". Accepts boolean operators. |
page |
a particular page of results to return. Useful when returning multiple sets of data with the same query;
you can repeat the query, incrementing the value in |
page_size |
the maximum number of items to return; anywhere between 1 and 50. Set to 50 by default. |
fields |
additional fields to include in the returned data (when available). Possible values (which should appear in a vector) appear here. |
collapse |
whether to collapse the actual content into a data.frame. Set to TRUE by default. |
... |
further arguments to pass to httr's |
guardian_tags
to retrieve metadata about tags.
# Simple example ## Not run: result <- guardian_content("test", "debate AND economy") ## End(Not run)
# Simple example ## Not run: result <- guardian_content("test", "debate AND economy") ## End(Not run)
guardian_editions
lets you directly search
The Guardian for metadata about their editions - country-specific
(or international) standard releases for their website's content.
guardian_editions(api_key, query, ...)
guardian_editions(api_key, query, ...)
api_key |
A key to the Guardian API, which can be obtained here. |
query |
Your search query. |
... |
further arguments to pass to httr's |
guardian_sections
for retrieving sections, another category
of content.
## Not run: # Simple example uk_edition_data <- guardian_editions("test", "uk") ## End(Not run)
## Not run: # Simple example uk_edition_data <- guardian_editions("test", "uk") ## End(Not run)
guardian_sections
lets you directly search
The Guardian for metadata about sections - individual categories of
content, such as world or US news.
guardian_sections(api_key, query, ...)
guardian_sections(api_key, query, ...)
api_key |
A key to the Guardian API, which can be obtained here. |
query |
Your search query. This can contain operators ( |
... |
further arguments to pass to httr's |
guardian_tags
for retrieving tags, another class
of content metadata.
## Not run: # Simple example business_sections <- guardian_sections("test", "business") ## End(Not run)
## Not run: # Simple example business_sections <- guardian_sections("test", "business") ## End(Not run)
guardian_tags
lets you directly search
The Guardian for their tags - metadata used to classify content.
guardian_tags(api_key, query, section = NULL, reference = NULL, reference_type = NULL, page = NULL, page_size = 50, ...)
guardian_tags(api_key, query, section = NULL, reference = NULL, reference_type = NULL, page = NULL, page_size = 50, ...)
api_key |
A key to the Guardian API, which can be obtained here. |
query |
Your search query. This can contain operators ( |
section |
the section, or sections, of The Guardian that you want to limit the search to. Multiple
sections may be concatenated together using boolean operators; see |
reference |
the references to limit the search to; only tags that include those references (and meet other conditions) will be returned. Also accepts boolean operators. |
reference_type |
the type of reference (such as |
page |
a particular page of results to return. Useful when returning multiple sets of data with the same query;
you can repeat the query, incrementing the value in |
page_size |
the maximum number of items to return; anywhere between 1 and 50. Set to 50 by default. |
... |
further arguments to pass to httr's |
## Not run: # Simple example results <- guardian_tags("test", "green") ## End(Not run)
## Not run: # Simple example results <- guardian_tags("test", "green") ## End(Not run)
This package provides a modern (httr/curl/jsonlite-based) API client for The Guardian (https://guardian.co.uk), allowing useRs to retrieve content and content metadata.