### Sample Ruby Request Source: https://api.thenounproject.com/getting_started A Ruby example demonstrating how to make a request to The Noun Project API using the `oauth` gem. ```APIDOC ## GET /v2/icon/{icon_id} ### Description Retrieves details for a specific icon. ### Method GET ### Endpoint https://api.thenounproject.com/v2/icon/{icon_id} ### Path Parameters - **icon_id** (integer) - Required - The unique identifier of the icon. ### Request Example ```ruby require "oauth" consumer = OAuth::Consumer.new("your-api-key", "your-api-secret") access_token = OAuth::AccessToken.new consumer endpoint = "https://api.thenounproject.com/v2/icon/1" response = access_token.get(endpoint) puts response.body ``` ### Response #### Success Response (200) - **icon** (object) - Details of the requested icon. #### Response Example ```json { "icon": { "id": 1, "name": "noun", "slug": "noun", "preview_url": "https://.../noun.png", "tags": ["symbol", "glyph"] } } ``` ``` -------------------------------- ### Sample Python Request Source: https://api.thenounproject.com/getting_started A Python example demonstrating how to make a request to The Noun Project API using the `requests` and `requests_oauthlib` libraries. ```APIDOC ## GET /v2/icon/{icon_id} ### Description Retrieves details for a specific icon. ### Method GET ### Endpoint https://api.thenounproject.com/v2/icon/{icon_id} ### Path Parameters - **icon_id** (integer) - Required - The unique identifier of the icon. ### Request Example ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon/1" response = requests.get(endpoint, auth=auth) print(response.content) ``` ### Response #### Success Response (200) - **icon** (object) - Details of the requested icon. #### Response Example ```json { "icon": { "id": 1, "name": "noun", "slug": "noun", "preview_url": "https://.../noun.png", "tags": ["symbol", "glyph"] } } ``` ``` -------------------------------- ### Noun Project API Overview Source: https://api.thenounproject.com/index This section outlines the general getting started guide and core concepts for interacting with the Noun Project API. ```APIDOC ## Noun Project API Overview ### Description This section provides an overview of how to get started with the Noun Project API, including key concepts and resources. ### Key Sections * **Getting Started:** * Creating an API Key * Authentication * Making Requests * Supported File Formats and HTTP Responses * Pricing * Unacceptable Uses * Sample Code * Icon Style Filtering * V1 Documentation & Explorer * **API Documentation:** * Blacklist * Usage * Icon * Collection * Autocomplete * **API Explorer:** * An interactive tool to explore API capabilities. ``` -------------------------------- ### API v2 Icon Search Filtering Examples Source: https://api.thenounproject.com/getting_started These examples showcase how to use query parameters in API v2 requests to filter icon search results. They demonstrate filtering by style (solid, line, or both) and by line weight, including single values and ranges. These parameters are crucial for refining search results based on visual attributes. ```http GET https://api.thenounproject.com/v2/icon?query=dog&styles=line GET https://api.thenounproject.com/v2/icon?query=dog&styles=solid GET https://api.thenounproject.com/v2/icon?query=dog&styles=line,solid GET https://api.thenounproject.com/v2/icon?query=cat&styles=line&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&styles=solid,line&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&line_weight=18-20 ``` -------------------------------- ### Python API Request with OAuth1 Authentication Source: https://api.thenounproject.com/getting_started This Python snippet demonstrates how to make a GET request to The Noun Project API using the `requests` and `requests_oauthlib` libraries. It shows how to set up OAuth1 authentication with your API key and secret, and how to send the authenticated request to a specific endpoint. The response content is then printed. ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon/1" response = requests.get(endpoint, auth=auth) print(response.content) ``` -------------------------------- ### Ruby API Request with OAuth Authentication Source: https://api.thenounproject.com/getting_started This Ruby snippet illustrates how to interact with The Noun Project API using the `oauth` gem. It explains how to initialize an OAuth consumer with your API key and secret, create an access token, and then use this token to make a GET request to an API endpoint. The response body is printed to the console. ```ruby require "oauth" consumer = OAuth::Consumer.new("your-api-key", "your-api-secret") access_token = OAuth::AccessToken.new consumer endpoint = "https://api.thenounproject.com/v2/icon/1" response = access_token.get(endpoint) puts response.body ``` -------------------------------- ### Search Icons (API v1 Response Example) Source: https://api.thenounproject.com/migration_v2 This snippet shows an example of the JSON response structure for the v1 icon search endpoint. It includes details about icon attribution, URLs, tags, and uploader information. Note that some keys have been renamed or simplified in newer versions. ```json { "generated_at": "Wed, 22 Mar 2023 22:56:06 GMT", "icons": [ { "attribution": "test by ChangHoon Baek from Noun Project", "attribution_preview_url": "https://static.thenounproject.com/attribution/84093-600.png", "collections": [], "date_uploaded": "2014-11-19", "icon_url": "https://static.thenounproject.com/noun-svg/84093.svg", "id": "84093", "is_active": "1", "is_explicit": "0", "license_description": "creative-commons-attribution", "nounji_free": "0", "permalink": "/term/test/84093", "preview_url": "https://static.thenounproject.com/png/84093-200.png", "preview_url_42": "https://static.thenounproject.com/png/84093-42.png", "preview_url_84": "https://static.thenounproject.com/png/84093-84.png", "sponsor": {}, "sponsor_campaign_link": null, "sponsor_id": "", "tags": [ { "id": 3430, "slug": "test" }, { "id": 7517, "slug": "user-interface" }, { "id": 11284, "slug": "user-experience" }, { "id": 19319, "slug": "ui" }, { "id": 6147, "slug": "register" }, { "id": 469, "slug": "paper" }, { "id": 4065, "slug": "list" }, { "id": 6032, "slug": "form" }, { "id": 2286, "slug": "design" }, { "id": 4903, "slug": "checklist" }, { "id": 1149, "slug": "check" }, { "id": 1290, "slug": "" }, { "id": 6757, "slug": "ux" } ], "term": "test", "term_id": 3430, "term_slug": "test", "updated_at": "2019-04-22 19:22:17", "uploader": { "location": "Toronto, ON, CA", "name": "ChangHoon Baek", "permalink": "/changhoon.baek.50", "username": "changhoon.baek.50" }, "uploader_id": "37574", "year": 2014 }, { "attribution": "test by Arthur Shlain from Noun Project", "attribution_preview_url": "https://static.thenounproject.com/attribution/247442-600.png", "collections": [ { "author": { "location": "", "name": "Arthur Shlain", "permalink": "/ArtZ91", "username": "ArtZ91" }, "author_id": "15311", "date_created": "2014-08-20 19:59:47", "date_updated": "2015-08-25 19:15:04", "description": "", "id": "866", "is_collaborative": "", "is_featured": "0", "is_published": "1", "is_store_item": "0", "name": "Assemblage", "permalink": "/ArtZ91/collection/assemblage", "slug": "assemblage", "sponsor": {}, "sponsor_campaign_link": "", "sponsor_id": "", "tags": [], "template": "24" } ], "date_uploaded": "2015-11-13", "icon_url": "https://static.thenounproject.com/noun-svg/247442.svg", "id": "247442", "is_active": "1", "is_explicit": "0", "license_description": "creative-commons-attribution", "nounji_free": "0", "permalink": "/term/test/247442", "preview_url": "https://static.thenounproject.com/png/247442-200.png", "preview_url_42": "https://static.thenounproject.com/png/247442-42.png", "preview_url_84": "https://static.thenounproject.com/png/247442-84.png", "sponsor": {}, "sponsor_campaign_link": null, "sponsor_id": "", "tags": [ { "id": 3430, "slug": "test" }, { "id": 5282, "slug": "tasks" }, { "id": 8435, "slug": "result" }, { "id": 4875, "slug": "plan" }, { "id": 11469, "slug": "grade" }, { "id": 3149, "slug": "goal" }, { "id": 8540, "slug": "exam" } ] } ] } ``` -------------------------------- ### Icon Search with Style and Line Weight Filtering (API v2) Source: https://api.thenounproject.com/getting_started This section details how to filter icon search results by style (solid, line) and, for line icons, by line weight. It applies only to API v2 endpoints. ```APIDOC ## GET /v2/icon ### Description Searches for icons and allows filtering by style and line weight. ### Method GET ### Endpoint https://api.thenounproject.com/v2/icon ### Query Parameters - **query** (string) - Required - The search term for icons. - **styles** (string) - Optional - Comma-separated list of styles (e.g., "solid", "line"). - **line_weight** (integer or string) - Optional - For line icons, specifies a single line weight (e.g., 20) or a range (e.g., "18-20"). Valid range is 1-60. ### Request Example ``` GET https://api.thenounproject.com/v2/icon?query=dog&styles=line GET https://api.thenounproject.com/v2/icon?query=dog&styles=solid GET https://api.thenounproject.com/v2/icon?query=dog&styles=line,solid GET https://api.thenounproject.com/v2/icon?query=cat&styles=line&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&styles=solid,line&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&line_weight=20 GET https://api.thenounproject.com/v2/icon?query=cat&line_weight=18-20 ``` ### Response #### Success Response (200) - **icons** (array) - List of icon objects matching the search criteria. - **noun** (object) - Information about the search query. #### Response Example ```json { "icons": [ { "id": 12345, "name": "dog", "slug": "dog", "preview_url": "https://.../dog.png", "tags": ["animal", "pet"] } ], "noun": { "total": 1000, "offset": 0, "limit": 100 } } ``` ``` -------------------------------- ### Fetch Noun Project Icon Data using Node.js OAuth Source: https://api.thenounproject.com/_sources/examples/nodejs_example This Node.js script uses the 'oauth' library to authenticate with The Noun Project API and fetch data for a specific icon. Ensure you install the 'oauth' package using 'npm install oauth'. Replace placeholders with your actual API key and secret. ```javascript var OAuth = require('oauth') // `npm install oauth` to satisfy // website: https://github.com/ciaranj/node-oauth var KEY = "" var SECRET = "" var oauth = new OAuth.OAuth( 'https://api.thenounproject.com', 'https://api.thenounproject.com', KEY, SECRET, '1.0', null, 'HMAC-SHA1' ) oauth.get( 'https://api.thenounproject.com/v2/icon/6324', null, null, function (e, data, res){ if (e) console.error(e) console.log(require('util').inspect(data)) } ) ``` -------------------------------- ### API v1 Single Icon Response Example (JSON) Source: https://api.thenounproject.com/migration_v2 Demonstrates the JSON response structure for retrieving a single icon using API v1. This includes details like icon URL, preview URLs, author information, and tags. ```json { "icon": { "attribution": "Trash by AIGA from Noun Project", "collections": [ { "author": { "location": "US", "name": "AIGA", "permalink": "/aiga-icons", "username": "aiga-icons" }, "author_id": "3805019", "date_created": "2012-01-27 19:15:26", "date_updated": "2018-04-17 20:37:44", "description": "", "id": "3", "is_collaborative": "", "is_featured": "1", "is_published": "1", "is_store_item": "0", "name": "Symbol Signs", "permalink": "/aiga-icons/collection/symbol-signs", "slug": "symbol-signs", "sponsor": {}, "sponsor_campaign_link": "", "sponsor_id": "", "tags": [], "template": "24" } ], "date_uploaded": "", "icon_url": "https://static.thenounproject.com/noun-svg/1.svg", "id": "1", "is_active": "1", "is_explicit": "0", "license_description": "public-domain", "nounji_free": "0", "permalink": "/term/trash/1", "preview_url": "https://static.thenounproject.com/png/1-200.png", "preview_url_42": "https://static.thenounproject.com/png/1-42.png", "preview_url_84": "https://static.thenounproject.com/png/1-84.png", "sponsor": {}, "sponsor_campaign_link": null, "sponsor_id": "", "tags": [ { "id": 19, "slug": "trash" }, { "id": 20, "slug": "garbage" }, { "id": 1974, "slug": "trash-can" }, { "id": 11120, "slug": "throw-away" } ], "term": "Trash", "term_id": 19, "term_slug": "trash", "updated_at": "2019-04-22 19:22:17", "uploader": { "location": "US", "name": "AIGA", "permalink": "/aiga-icons", "username": "aiga-icons" }, "uploader_id": "3805019", "year": 1974 } } ``` -------------------------------- ### Noun Project API v2 Response Example Source: https://api.thenounproject.com/_sources/migration_v2 This JSON structure represents a typical response from the Noun Project API v2 when requesting icons. It includes metadata about the icons, pagination information, and usage limits. ```json { "generated_at": "2023-03-22 22:58:39.517834", "icons": [ { "attribution": "test by ChangHoon Baek from Noun Project", "collections": [], "creator": { "name": "ChangHoon Baek", "permalink": "/changhoon.baek.50", "username": "changhoon.baek.50" }, "icon_url": "https://static.thenounproject.com/svg_clean/84093.svg", "id": "84093", "license_description": "creative-commons-attribution", "permalink": "/term/test/84093", "tags": [ "test", "user-interface", "user-experience", "ui", "register", "paper", "list", "form", "design", "checklist", "check", "ux" ], "term": "test", "thumbnail_url": "https://static.thenounproject.com/png/84093-200.png", "updated_at": "2019-04-22 19:22:17" }, { "attribution": "test by Nur Achmadi Yusuf from Noun Project", "collections": [ { "creator": { "name": "Nur Achmadi Yusuf", "permalink": "/achmadi9", "username": "achmadi9" }, "id": "179852", "name": "Corporate Line", "permalink": "/achmadi9/collection/corporate-line" } ], "creator": { "name": "Nur Achmadi Yusuf", "permalink": "/achmadi9", "username": "achmadi9" }, "icon_url": "https://static.thenounproject.com/svg_clean/5455842.svg", "id": "5455842", "license_description": "creative-commons-attribution", "permalink": "/term/test/5455842", "tags": [ "test", "clipboard", "document", "education", "exam", "list" ], "term": "test", "thumbnail_url": "https://static.thenounproject.com/png/5455842-200.png", "updated_at": "2023-01-24 22:43:51" } ], "next_page": "31352E302C35343535383432", "total": 12791, "usage_limits": { "monthly": { "limit": 5000, "usage": 31 } } } ``` -------------------------------- ### Search Icons (v1) Source: https://api.thenounproject.com/migration_v2 This section details how to search for icons using the v1 of the Noun Project API. It shows how to make a GET request to the icons endpoint. ```APIDOC ## GET /icons ### Description Searches for icons based on a query. This uses the v1 of the API. ### Method GET ### Endpoint `https://api.thenounproject.com/icons/{search_term}` ### Parameters #### Path Parameters - **search_term** (string) - Required - The term to search for icons. ### Request Example ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/icons/test" response = requests.get(endpoint, auth=auth) response_json = response.json() for icon in response_json["icons"]: icon_url = icon["icon_url"] thumbnail_url = icon["preview_url"] title = icon["term"] tags = icon["tags"] license = icon["license_description"] ``` ### Response #### Success Response (200) - **icons** (array) - A list of icon objects. - **icon_url** (string) - The URL of the icon. - **preview_url** (string) - The URL of the icon preview. - **term** (string) - The title or term associated with the icon. - **tags** (array) - A list of tags for the icon. - **license_description** (string) - The description of the icon's license. #### Response Example ```json { "icons": [ { "icon_url": "https://...", "preview_url": "https://...", "term": "test", "tags": ["tag1", "tag2"], "license_description": "Some License" } ] } ``` ``` -------------------------------- ### API v2 Single Icon Response Example (JSON) Source: https://api.thenounproject.com/migration_v2 Illustrates the JSON response structure for fetching a single icon using API v2. Highlights changes such as renamed keys (e.g., `preview_url` to `thumbnail_url`), simplified structures, and added usage data. ```json { "generated_at": "2023-03-22 23:04:03.209789", "icon": { "attribution": "Trash by AIGA from Noun Project", "collections": [ { "creator": { "name": "AIGA", "permalink": "/aiga-icons", "username": "aiga-icons" }, "id": "3", "name": "Symbol Signs", "permalink": "/aiga-icons/collection/symbol-signs" } ], "creator": { "name": "AIGA", "permalink": "/aiga-icons", "username": "aiga-icons" }, "icon_url": "https://static.thenounproject.com/svg_clean/1.svg", "id": "1", "license_description": "public-domain", "permalink": "/term/trash/1", "tags": [ "trash", "garbage", "trash-can", "throw-away" ], "term": "Trash", "thumbnail_url": "https://static.thenounproject.com/png/1-200.png", "updated_at": "2019-04-22 19:22:17" }, "total": 1, "usage_limits": { "monthly": { "limit": 5000, "usage": 32 } } } ``` -------------------------------- ### Node.js Project Dependencies for Noun Project API Source: https://api.thenounproject.com/_sources/examples/nodejs_example This package.json file lists the necessary dependencies for the Node.js example, specifically the 'oauth' library, which is required for authenticating with The Noun Project API. ```json { "dependencies": { "oauth": "^0.9.12" } } ``` -------------------------------- ### Build URL for GET Request in PHP Source: https://api.thenounproject.com/_sources/examples/php_example This PHP function constructs a URL suitable for a GET request. It first normalizes the base URL using `get_normalized_http_url` and then appends the POST data (generated by `to_postdata`) as a query string if available. This is useful for preparing API requests. ```php public function to_url() { $post_data = $this->to_postdata(); $out = $this->get_normalized_http_url(); if ($post_data) { $out .= "?" . $post_data; } return $out; } ``` -------------------------------- ### Make Simple API Call in C# Source: https://api.thenounproject.com/examples/csharp_example This C# snippet shows how to make a basic GET request to The Noun Project API. It requires the RestSharp library and OAuth1 authentication. The output is the raw content of the API response. ```csharp using RestSharp; using RestSharp.Authenticators; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Request { class NounProjectAPI { void SimpleCall() { var baseUrl = new Uri("https://api.thenounproject.com"); var client = new RestClient(baseUrl); client.Authenticator = OAuth1Authenticator.ForRequestToken("CLIENT_KEY_HERE", "CLIENT_SECRET_HERE"); var request = new RestRequest("/v2/icon/1", Method.GET); IRestResponse response = client.Execute(request); var content = response.Content; } } } ``` -------------------------------- ### Search Icons (v2) Source: https://api.thenounproject.com/migration_v2 This section details how to search for icons using the v2 of the Noun Project API. It shows how to make a GET request to the v2/icon endpoint with query parameters. ```APIDOC ## GET /v2/icon ### Description Searches for icons using the v2 of the Noun Project API. This endpoint allows for more specific search queries and options like including SVG. ### Method GET ### Endpoint `https://api.thenounproject.com/v2/icon` ### Parameters #### Query Parameters - **query** (string) - Required - The search term for icons. - **include_svg** (integer) - Optional - Set to 1 to include SVG versions of icons in the response. ### Request Example ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon?query=test&include_svg=1" response = requests.get(endpoint, auth=auth) response_json = response.json() for icon in response_json["icons"]: icon_url = icon["icon_url"] thumbnail_url = icon["thumbnail_url"] title = icon["term"] tags = icon["tags"] license = icon["license_description"] ``` ### Response #### Success Response (200) - **icons** (array) - A list of icon objects. - **icon_url** (string) - The URL of the icon. - **thumbnail_url** (string) - The URL of the icon thumbnail. - **term** (string) - The title or term associated with the icon. - **tags** (array) - A list of tags for the icon. - **license_description** (string) - The description of the icon's license. - **svg_url** (string, optional) - The URL of the SVG version of the icon, if `include_svg` was set to 1. #### Response Example ```json { "icons": [ { "icon_url": "https://...", "thumbnail_url": "https://...", "term": "test", "tags": ["tag1", "tag2"], "license_description": "Some License", "svg_url": "https://..." } ] } ``` ``` -------------------------------- ### Node.js OAuth Authentication for The Noun Project API Source: https://api.thenounproject.com/examples/nodejs_example This Node.js script demonstrates how to authenticate with The Noun Project API using OAuth. It requires the 'oauth' npm package. The script sets up the OAuth client with provided keys and then makes a GET request to retrieve icon data. ```javascript var OAuth = require('oauth') // `npm install oauth` to satisfy // website: https://github.com/ciaranj/node-oauth var KEY = "" var SECRET = "" var oauth = new OAuth.OAuth( 'https://api.thenounproject.com', 'https://api.thenounproject.com', KEY, SECRET, '1.0', null, 'HMAC-SHA1' )oauth.get( 'https://api.thenounproject.com/v2/icon/6324', null, null, function (e, data, res){ if (e) console.error(e) console.log(require('util').inspect(data)) } ) ``` ```json { "dependencies": { "oauth": "^0.9.12" } } ``` -------------------------------- ### Manage OAuth Request Parameters Source: https://api.thenounproject.com/_sources/examples/php_example Provides methods to set, get, retrieve all, and unset individual parameters for an OAuth request. The set_parameter method supports handling duplicate parameter names by storing them in an array. ```php public function set_parameter($name, $value, $allow_duplicates = true) { if ($allow_duplicates && isset($this->parameters[$name])) { // We have already added parameter(s) with this name, so add to the list if (is_scalar($this->parameters[$name])) { // This is the first duplicate, so transform scalar (string) // into an array so we can add the duplicates $this->parameters[$name] = [$this->parameters[$name]]; } $this->parameters[$name][] = $value; } else { $this->parameters[$name] = $value; } } public function get_parameter($name) { return isset($this->parameters[$name]) ? $this->parameters[$name] : null; } public function get_parameters() { return $this->parameters; } public function unset_parameter($name) { unset($this->parameters[$name]); } ``` -------------------------------- ### Get Signable Parameters for OAuth Source: https://api.thenounproject.com/_sources/examples/php_example Retrieves all parameters for the OAuth request, excluding the 'oauth_signature' parameter itself, and builds an HTTP query string from them. This is used in generating the signature base string. ```php public function get_signable_parameters() { // Grab all parameters $params = $this->parameters; // Remove oauth_signature if present // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.") if (isset($params["oauth_signature"])) { unset($params["oauth_signature"]); } return OAuthUtil::build_http_query($params); ``` -------------------------------- ### Requesting an Icon by ID (v1 Python Example) Source: https://api.thenounproject.com/migration_v2 Demonstrates how to request an icon by its ID using the v1 version of The Noun Project API with Python's requests library. It shows how to authenticate, construct the endpoint, make the request, and extract icon details like URL, thumbnail, title, tags, and license. ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/icon/1" response = requests.get(endpoint, auth=auth) response_json = response.json() icon_url = response_json["icon"]["icon_url"] thumbnail_url = response_json["icon"]["preview_url"] title = response_json["icon"]["term"] tags = response_json["icon"]["tags"] license = response_json["icon"]["license_description"] ``` -------------------------------- ### Requesting an Icon by ID (v2 Python Example) Source: https://api.thenounproject.com/migration_v2 Demonstrates how to request an icon by its ID using the v2 version of The Noun Project API with Python's requests library. It shows the updated endpoint structure and extraction of icon details, noting the change in the thumbnail URL key from 'preview_url' to 'thumbnail_url'. ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon/1" response = requests.get(endpoint, auth=auth) response_json = response.json() icon_url = response_json["icon"]["icon_url"] thumbnail_url = response_json["icon"]["thumbnail_url"] title = response_json["icon"]["term"] tags = response_json["icon"]["tags"] license = response_json["icon"]["license_description"] ``` -------------------------------- ### Search Icons with The Noun Project API v2 (Python) Source: https://api.thenounproject.com/_sources/migration_v2 This snippet demonstrates searching for icons using the v2 endpoint of The Noun Project API. It utilizes the `requests` library and `requests_oauthlib` for authentication. The example includes fetching icon details such as URL, thumbnail, title, tags, and license from the v2 API's JSON response, with an option to include SVGs. ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon?query=test&include_svg=1" response = requests.get(endpoint, auth=auth) response_json = response.json() for icon in response_json["icons"]: icon_url = icon["icon_url"] thumbnail_url = icon["thumbnail_url"] title = icon["term"] tags = icon["tags"] license = icon["license_description"] ``` -------------------------------- ### Retrieve Icon Data Example Source: https://api.thenounproject.com/documentation_v1 This snippet shows an example of data returned for an icon from The Noun Project API. It includes details such as attribution, URLs for different preview sizes, upload date, license, and uploader information. This data is typically part of a larger response when querying for icons. ```json { "attribution": "Fish by Teresa S Garner from The Noun Project", "attribution_preview_url": "https://static.thenounproject.com/attribution/24913-600.png", "collections": [], "date_uploaded": "2013-10-20", "icon_url": "https://static.thenounproject.com/svg/3671fe0b-56db-498f-ba71-5c344379a126.svg?Expires=1425590518&Signature=K9dLQGWzwpkomOhio2Ob0QkuSKLlgHej8~~mLZxLLtNcs4hvsQauKlW96JR36uO7mZq~YKjLpQCJ-cDsEHdUnle9hp1PDAznugHyWLPxJXQq~QTmpaQQZn1IBPwXXpab~FD9nCwSn8uQnSpNwStN9qsqrPrCwOs2zOpHeGdzwhw_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q", "id": "24913", "is_active": "1", "license_description": "public-domain", "permalink": "/term/fish/24913", "preview_url": "https://static.thenounproject.com/png/24913-200.png", "preview_url_42": "https://static.thenounproject.com/png/24913-42.png", "preview_url_84": "https://static.thenounproject.com/png/24913-84.png", "sponsor": {}, "sponsor_campaign_link": null, "sponsor_id": "", "term": "Fish", "term_id": 246, "term_slug": "fish", "uploader": { "location": "US", "name": "Teresa S Garner", "permalink": "/sgarner", "username": "sgarner" }, "uploader_id": "214620", "year": 2013 } ``` -------------------------------- ### Get Icon by ID - HTTP Request Source: https://api.thenounproject.com/documentation_v1 This snippet demonstrates how to make an HTTP GET request to retrieve a single icon using its unique integer ID. It includes an example of how to optionally request a 1200x1200 PNG. ```http GET http://api.thenounproject.com/icon/15 ``` -------------------------------- ### Get Icon by ID (v2) Source: https://api.thenounproject.com/migration_v2 Retrieves icon details by its ID using the v2 API. ```APIDOC ## GET /v2/icon/{id} ### Description Retrieves details for a specific icon using its unique ID via the v2 API. ### Method GET ### Endpoint /v2/icon/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the icon. ### Request Example ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/v2/icon/1" response = requests.get(endpoint, auth=auth) response_json = response.json() icon_url = response_json["icon"]["icon_url"] thumbnail_url = response_json["icon"]["thumbnail_url"] title = response_json["icon"]["term"] tags = response_json["icon"]["tags"] license = response_json["icon"]["license_description"] ``` ### Response #### Success Response (200) - **icon** (object) - Contains details about the icon. - **icon_url** (string) - The URL of the icon SVG. - **thumbnail_url** (string) - The URL of the icon thumbnail. - **term** (string) - The title or term associated with the icon. - **tags** (array of strings) - A list of tags associated with the icon. - **license_description** (string) - The license under which the icon is available. #### Response Example ```json { "icon": { "icon_url": "https://static.thenounproject.com/svg_clean/84093.svg", "thumbnail_url": "https://static.thenounproject.com/png/84093-200.png", "term": "test", "tags": [ "test", "user-interface", "user-experience", "ui", "register", "paper", "list", "form", "design", "checklist", "check", "ux" ], "license_description": "creative-commons-attribution" } } ``` ``` -------------------------------- ### Get Icon by ID (v1) Source: https://api.thenounproject.com/migration_v2 Retrieves icon details by its ID using the v1 API. ```APIDOC ## GET /icon/{id} ### Description Retrieves details for a specific icon using its unique ID. ### Method GET ### Endpoint /icon/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the icon. ### Request Example ```python import requests from requests_oauthlib import OAuth1 auth = OAuth1("your-api-key", "your-api-secret") endpoint = "https://api.thenounproject.com/icon/1" response = requests.get(endpoint, auth=auth) response_json = response.json() icon_url = response_json["icon"]["icon_url"] thumbnail_url = response_json["icon"]["preview_url"] title = response_json["icon"]["term"] tags = response_json["icon"]["tags"] license = response_json["icon"]["license_description"] ``` ### Response #### Success Response (200) - **icon** (object) - Contains details about the icon. - **icon_url** (string) - The URL of the icon SVG. - **preview_url** (string) - The URL of the icon preview image. - **term** (string) - The title or term associated with the icon. - **tags** (array of strings) - A list of tags associated with the icon. - **license_description** (string) - The license under which the icon is available. #### Response Example ```json { "icon": { "icon_url": "https://static.thenounproject.com/svg_clean/84093.svg", "preview_url": "https://static.thenounproject.com/png/84093-200.png", "term": "test", "tags": [ "test", "user-interface", "user-experience", "ui", "register", "paper", "list", "form", "design", "checklist", "check", "ux" ], "license_description": "creative-commons-attribution" } } ``` ``` -------------------------------- ### Sample Request (Ruby) Source: https://api.thenounproject.com/_sources/getting_started Example of how to make an authenticated API request using Ruby and the oauth gem. ```APIDOC ## Making Authenticated Requests with Ruby ### Description This snippet shows how to authenticate and make a GET request to a Noun Project API endpoint using Ruby. ### Method GET ### Endpoint https://api.thenounproject.com/v2/icon/{icon_id} ### Parameters #### Path Parameters - **icon_id** (integer) - Required - The ID of the icon to retrieve. ### Request Example ```ruby require "oauth" # Replace with your actual API key and secret api_key = "your-api-key" api_secret = "your-api-secret" consumer = OAuth::Consumer.new(api_key, api_secret) access_token = OAuth::AccessToken.new consumer endpoint = "https://api.thenounproject.com/v2/icon/1" # Example icon ID begin response = access_token.get(endpoint) puts response.body rescue OAuth::Error => e puts "An OAuth error occurred: #{e.message}" rescue StandardError => e puts "An unexpected error occurred: #{e.message}" end ``` ### Response #### Success Response (200) Returns the icon data in JSON format. #### Response Example ```json { "icon": { "id": 1, "name": "Example Icon", "tags": ["example", "icon"], "preview_url": "https://.../example.svg" } } ``` ``` -------------------------------- ### Sample Request (Python) Source: https://api.thenounproject.com/_sources/getting_started Example of how to make an authenticated API request using Python and the requests_oauthlib library. ```APIDOC ## Making Authenticated Requests with Python ### Description This snippet shows how to authenticate and make a GET request to a Noun Project API endpoint using Python. ### Method GET ### Endpoint https://api.thenounproject.com/v2/icon/{icon_id} ### Parameters #### Path Parameters - **icon_id** (integer) - Required - The ID of the icon to retrieve. ### Request Example ```python import requests from requests_oauthlib import OAuth1 # Replace with your actual API key and secret api_key = "your-api-key" api_secret = "your-api-secret" auth = OAuth1(api_key, api_secret) endpoint = "https://api.thenounproject.com/v2/icon/1" # Example icon ID try: response = requests.get(endpoint, auth=auth) response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) print(response.content) except requests.exceptions.RequestException as e: print(f"An error occurred: {e}") ``` ### Response #### Success Response (200) Returns the icon data in JSON format. #### Response Example ```json { "icon": { "id": 1, "name": "Example Icon", "tags": ["example", "icon"], "preview_url": "https://.../example.svg" } } ``` ``` -------------------------------- ### GET /v2/oauth/usage Source: https://api.thenounproject.com/migration_v2 Retrieves OAuth usage data. This is the v2 equivalent of the v1 `/oauth/usage` endpoint, providing insights into API consumption. ```APIDOC ## GET /v2/oauth/usage ### Description Retrieves current OAuth usage statistics. This endpoint is the v2 version of the v1 `/oauth/usage` endpoint. ### Method GET ### Endpoint `/v2/oauth/usage` ### Parameters None. ### Request Example ```json { "example": "GET /v2/oauth/usage" } ``` ### Response #### Success Response (200) - **usage** (object) - Contains details about API usage. - **monthly** (object) - Monthly usage data. - **limit** (integer) - The monthly usage limit. - **usage** (integer) - The current monthly usage count. #### Response Example ```json { "usage": { "monthly": { "limit": 5000, "usage": 32 } } } ``` ```