Icons¶
-
class
TheNounProjectAPI.icons.
Icons
(key=None, secret=None, testing=False, timeout=5.0)¶ Bases:
TheNounProjectAPI.core.Core
Construct a new object for making API requests.
- Parameters
key (str) – The API key from the TheNounProject API. (defaults to None)
secret (str) – The secret key from the TheNounProject API. (defaults to None)
testing (bool) – Whether the methods should return a PreparedRequest, instead of data from the API. Should not be used except for testing this wrapper. (defaults to False)
timeout (Union[float, Tuple[float, float], None]) – Float timeout in seconds, 2-tuples for seperate connect and read timeouts, and None for no timeout. (defaults to 5.0)
-
get_collection_icons_by_id
(_id, limit=None, offset=None, page=None)¶ Fetches collection Icons by id from the API.
- Parameters
_id (int) – Collection id.
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Raises
NonPositive – Raises exception when _id is nonpositive.
- Returns
List of IconModel objects from the collection identified by the _id.
- Return type
List[IconModel]
-
get_collection_icons_by_slug
(slug, limit=None, offset=None, page=None)¶ Fetches collection Icons by slug from the API.
- Parameters
slug (str) – Collection slug.
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Raises
IllegalSlug – Raises exception when slug is an empty string, contains non ascii characters or contains multiple words.
- Returns
List of IconModel objects from the collection identified by the slug.
- Return type
List[IconModel]
-
get_collection_icons
(identifier, limit=None, offset=None, page=None)¶ Fetches collection Icons, either by id or by slug.
- Parameters
identifier (Union[int, str]) – Collection identifier (id or slug).
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Raises
NonPositive – Raises exception when identifier is a nonpositive integer.
IllegalSlug – Raises exception when identifier is a string that’s empty, non-ascii or with multiple words.
- Returns
List of IconModel objects from the collection identified by the identifier.
- Return type
List[IconModel]
-
get_icon_by_id
(_id)¶ Fetches a single Icon by id.
- Parameters
_id (int) – Icon id.
- Raises
NonPositive – Raises exception when id is nonpositive.
- Returns
IconModel object identified by the _id.
- Return type
-
get_icon_by_term
(term)¶ Fetches a single Icon by term.
- Parameters
term (str) – Icon term.
- Raises
IllegalTerm – Raises exception when term is an empty string.
- Returns
IconModel object identified by the term.
- Return type
-
get_icon
(identifier)¶ Fetches single Icon, either by id or by term.
- Parameters
identifier (Union[int, str]) – Collection identifier (id or term).
- Raises
NonPositive – Raises exception when identifier is a nonpositive integer.
IllegalTerm – Raises exception when identifier is an empty string.
- Returns
IconModel object identified by the identifier.
- Return type
-
get_recent_icons
(limit=None, offset=None, page=None)¶ Fetches recent Icons.
- Parameters
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Returns
List of IconModel objects.
- Return type
List[IconModel]
-
get_icons_by_term
(term, public_domain_only=False, limit=None, offset=None, page=None)¶ Fetches a list of Icons by term.
- Parameters
term (str) – Collection term.
public_domain_only (Union[bool, int]) – Limit results to public domain icons only (defaults to False)
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Raises
IllegalTerm – Raises exception when term is an empty string.
- Returns
List of IconModel objects identified by the term.
- Return type
List[IconModel]
-
get_user_uploads
(username, limit=None, offset=None, page=None)¶ Fetches a list of uploads (Icons) associated with a user.
- Parameters
username (str) – Username.
public_domain_only – Limit results to public domain icons only (defaults to False)
limit (int) – Maximum number of results. (defaults to None)
offset (int) – Number of results to displace or skip over. (defaults to None)
page (int) – Number of results of limit length to displace or skip over. (defaults to None)
- Raises
IllegalTerm – Raises exception when username is an empty string.
- Returns
List of IconModel objects uploaded by user identified with the user_id.
- Return type
List[IconModel]