### List all categories with C# (setup) Source: https://docs.webshrinker.com/v3/website-category-api.html C# code snippet that sets up the API key, secret, and base URL for the categories endpoint. It is the beginning of a C# example for listing all categories. ```csharp using System; using System.Text; using System.Net; using System.IO; string apiKey = "your access key"; string apiSecret = "your secret key"; string apiUrl = "https://api.webshrinker.com/categories/v3"; ``` -------------------------------- ### Basic Authentication Header Example Source: https://docs.webshrinker.com/v1/userinfo-balance-api.html Example Authorization header using Basic authentication with base64-encoded credentials. The example uses access key 'c9542d01d69f' and secret key '17902c2c9b3a'. ```http Authorization: Basic Yzk1NDJkMDFkNjlmOjE3OTAyYzJjOWIzYQ== ``` -------------------------------- ### Basic HTTP Authentication in C# Source: https://docs.webshrinker.com/v3/website-category-api.html C# example using HttpWebRequest with Basic Authorization header. The response is read and printed to console. ```csharp using System; using System.Text; using System.Net; using System.IO; string apiKey = "your access key"; string apiSecret = "your secret key"; string apiUrl = "https://api.webshrinker.com/categories/v3"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl); request.ContentType = "application/json; charset=utf-8"; request.Headers["Authorization"] = "Basic " + Convert.ToBase64String( Encoding.GetEncoding("ISO-8859-1") .GetBytes(apiKey + ":" + apiSecret) ); request.PreAuthenticate = true; HttpWebResponse resp = request.GetResponse() as HttpWebResponse; using (Stream s = resp.GetResponseStream()) { StreamReader reader = new StreamReader(s, Encoding.UTF8); Console.WriteLine(reader.ReadToEnd()); } ``` -------------------------------- ### Python: Generate pre-signed URL and handle screenshot response Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Python example that builds a pre-signed URL for the Webshrinker API v2, sends a GET request, and handles status codes 200, 202, 400, 401, and 402. It saves the screenshot PNG on success or placeholder on 202. ```python try: from urllib import urlencode except ImportError: from urllib.parse import urlencode from base64 import urlsafe_b64encode import hashlib, requests def webshrinker_v2(access_key, secret_key, url, params): params['key'] = access_key request = "thumbnails/v2/%s?%s" % (urlsafe_b64encode(url).decode('utf-8'), urlencode(params, True)) signed = hashlib.md5("{}:{}".format(secret_key, request).encode('utf-8')).hexdigest() return "https://api.webshrinker.com/%s&hash=%s" % (request, signed) access_key = "your access key" secret_key = "your secret key" url = b"https://www.webshrinker.com" params = {'size': 'xlarge'} api_url = webshrinker_v2(access_key, secret_key, url, params) response = requests.get(api_url) if response.status_code == 200: with open("screenshot.png", "wb") as f: f.write(response.content) print("Screenshot saved to screenshot.png") elif response.status_code == 202: with open("screenshot.png", "wb") as f: f.write(response.content) print("Screenshot being generated, placeholder saved") elif response.status_code == 400: print("Bad or malformed HTTP request") elif response.status_code == 401: print("Unauthorized - check your keys") elif response.status_code == 402: print("Account request limit reached") else: print("A general error occurred, try again") ``` -------------------------------- ### GET /v2/{website} Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Retrieves a website screenshot with configurable parameters for size, delay, fullpage, and more. ```APIDOC ## [GET] /v2/{website} ### Description Retrieves a screenshot of a website. The response includes the screenshot image URL and its current state. ### Method GET ### Endpoint /v2/{website} ### Parameters #### Path Parameters - **website** (string) - Required - The website URL to capture, URL-encoded. #### Query Parameters - **key** (string) - Required* - Access key. Required for pre-signed URL auth. - **size** (string) - Required - Preset size name (e.g., `xlarge`) or custom `WxH` (e.g., `320x240`). - **delay** (integer) - Optional - Additional seconds to wait after page load before capturing. Default: 0. - **expires** (integer) - Optional - Unix timestamp after which the pre-signed URL expires. Default: 0. - **fullpage** (boolean) - Optional - Set to `true` to capture the full page height instead of the viewport. Default: false. - **hideadult** (integer) - Optional - Set to `1` to pixelate/blur screenshots of adult-categorized sites. Default: 0. - **refresh** (boolean) - Optional - Force a new screenshot, bypassing cached versions. Default: false. - **pixelate** (integer) - Optional - Blur intensity level. Options: `2`, `4`, `6`, `10`, `16`. Default varies. - **viewport** (string) - Optional - Browser window dimensions in `WxH` format. Default: 1280x1024. - **width** (integer) - Optional - Custom output width in pixels (max 2048). Overrides `size` width. - **_`** (string) - Optional - Cache buster — any value to bypass CDN caching. ### Request Example ``` GET /v2/https://www.webshrinker.com/?size=xlarge&key=TvQu6ARhl2Zs7BVV1plU ``` ### Response #### Success Response (200) - **data** (array) - Array of screenshot objects. - **image** (string) - URL of the screenshot image. - **state** (string) - Current state of the screenshot: `READY`, `REFRESH`, `PROCESSING`, or `ERROR`. - **updated** (string) - Timestamp of the last update. - **url** (string) - The website URL. #### Response Example ```json { "data": [ { "image": "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge&key=TvQu6ARhl2Zs7BVV1plU&hash=97462c219208614dec16cf9098433f6f", "state": "READY", "updated": "Mon, 30 May 2016 23:13:06 +0000", "url": "https://www.webshrinker.com/" } ] } ``` ### Error Handling - **400** - Bad or malformed HTTP request. - **401** - Unauthorized - check your keys. - **402** - Account request limit reached. - **429** - Too Many Requests - Rate limit exceeded. - **500** - Server Error - Internal server error. Retry the request. ### Notes - The `state` field indicates the screenshot status: `READY` (available), `REFRESH` (being regenerated, previous image still available), `PROCESSING` (being generated, no image yet), `ERROR` (could not be generated). - Screenshot sizes: `micro` (75x56), `tiny` (90x68), `verysmall` (100x75), `small` (120x90), `large` (200x150), `xlarge` (320x240), `2xlarge` (550x412), `3xlarge` (1024x768), `4xlarge` (1280x1024), or custom `WxH`. ``` -------------------------------- ### Basic HTTP Authentication in Python Source: https://docs.webshrinker.com/v3/website-category-api.html Python example using requests library with basic authentication. The response is parsed as JSON. ```python import requests access_key = "your access key" secret_key = "your secret key" response = requests.get( "https://api.webshrinker.com/categories/v3", auth=(access_key, secret_key) ) data = response.json() ``` -------------------------------- ### List all categories with curl Source: https://docs.webshrinker.com/v3/website-category-api.html Example curl commands for listing all categories. Shows both basic authentication with access and secret keys, and a pre-signed URL with key and hash parameters. ```shell # Using Basic Authentication curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3" # Using a pre-signed URL curl "https://api.webshrinker.com/categories/v3/?key=TvQu6ARhl2Zs7BVV1plU&hash=0f41d9264f05b2aeb0064fc6d7114cbc" ``` -------------------------------- ### List all categories with PHP Source: https://docs.webshrinker.com/v3/website-category-api.html PHP example that builds a pre-signed URL and makes a request to list all categories. It uses cURL to fetch the response and prints the decoded JSON. ```php ``` -------------------------------- ### JSON response: Screenshot ready (200 OK) Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Example response when the screenshot is ready, containing the image URL, state READY, updated timestamp, and the requested URL. ```json { "data": [ { "image": "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge&key=TvQu6ARhl2Zs7BVV1plU&hash=97462c219208614dec16cf9098433f6f", "state": "READY", "updated": "Mon, 30 May 2016 23:13:06 +0000", "url": "https://www.webshrinker.com/" } ] } ``` -------------------------------- ### Basic HTTP Authentication in PHP Source: https://docs.webshrinker.com/v3/website-category-api.html PHP example using cURL to set the Authorization header with access key and secret key. The response is fetched from the categories/v3 endpoint. ```php ``` -------------------------------- ### JSON response: Screenshot refreshing (200 OK) Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Example response when the screenshot is being refreshed, with state REFRESH and the previous image still available. ```json { "data": [ { "image": "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge&key=TvQu6ARhl2Zs7BVV1plU&hash=97462c219208614dec16cf9098433f6f", "state": "REFRESH", "updated": "Mon, 30 May 2016 18:03:26 +0000", "url": "https://www.webshrinker.com/" } ] } ``` -------------------------------- ### Successful Balance Response Source: https://docs.webshrinker.com/v1/userinfo-balance-api.html Example response body for a successful request, showing the remaining credits as a plain integer. ```text 99 ``` -------------------------------- ### Example API response JSON Source: https://docs.webshrinker.com/v3/website-category-api.html Example response from the Website Category API showing the structure of the returned JSON. The response contains a data array with a categories object that maps IAB taxonomy codes to category names. ```json { "data": [ { "categories": { "IAB1": { "IAB1": "Arts & Entertainment", "IAB1-1": "Books & Literature", "IAB1-2": "Celebrity Fan/Gossip", "IAB1-3": "Fine Art", "IAB1-4": "Humor", "IAB1-5": "Movies", "IAB1-6": "Music & Audio", "IAB1-7": "Television & Video" }, "IAB10": { "IAB10": "Home & Garden", "IAB10-1": "Appliances", "IAB10-2": "Entertaining", "IAB10-3": "Environmental Safety", "IAB10-4": "Gardening" } // ... all categories } } ] } ``` -------------------------------- ### List all categories with Python Source: https://docs.webshrinker.com/v3/website-category-api.html Python example that builds a pre-signed URL and uses the requests library to list all categories. It prints the JSON response with indentation if the status code is 200. ```python try: from urllib import urlencode except ImportError: from urllib.parse import urlencode from base64 import urlsafe_b64encode import hashlib, requests, json def webshrinker_categories_v3(access_key, secret_key, url=b"", params={}): params['key'] = access_key request = "categories/v3/{}?{}".format( urlsafe_b64encode(url).decode('utf-8'), urlencode(params, True)) signed = hashlib.md5("{}:{}".format(secret_key, request).encode()).hexdigest() return "https://api.webshrinker.com/{}&hash={}".format(request, signed) access_key = "your access key" secret_key = "your secret key" api_url = webshrinker_categories_v3(access_key, secret_key) response = requests.get(api_url) data = response.json() if response.status_code == 200: print(json.dumps(data, indent=4, sort_keys=True)) ``` -------------------------------- ### GET /categories/v3/{base64-encoded-url} Source: https://docs.webshrinker.com/v3/website-category-api.html This snippet documents the Category Lookup endpoint, which classifies a URL, domain, or IP address. It includes the endpoint path, query parameters, request examples, and response structure. ```APIDOC ## GET /categories/v3/{base64-encoded-url} ### Description Classify a specific URL, domain, or IP address. The target must be Base64-encoded before appending it to the endpoint path. ### Method GET ### Endpoint https://api.webshrinker.com/categories/v3/{base64-encoded-url} ### Parameters #### Path Parameters - **base64-encoded-url** (string) - Required - The URL-safe Base64-encoded target URL, domain, or IP address. #### Query Parameters - **key** (string) - Required* - Access key. Required only for pre-signed URL auth. - **expires** (integer) - Optional - Unix timestamp for URL expiration. Default: 0. - **taxonomy** (string) - Optional - `iabv1` or `webshrinker`. Default: `iabv1`. - **_`** (string) - Optional - Cache buster. ### Request Example ``` # d2Vic2hyaW5rZXIuY29t = base64("webshrinker.com") # Basic Authentication curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3/d2Vic2hyaW5rZXIuY29t" # Pre-signed URL curl "https://api.webshrinker.com/categories/v3/d2Vic2hyaW5rZXIuY29t?key=TvQu6ARhl2Zs7BVV1plU&hash=afe42ba2e8ae6f9d5ec2a0535ab484fe" ``` ### Response #### Success Response (200) - **data** (array) - Contains an object with a `categories` field. - **categories** (object) - Maps taxonomy IDs to category names. #### Response Example ``` { "data": [ { "categories": { "IAB1": { "IAB1": "Arts & Entertainment", "IAB1-1": "Books & Literature", "IAB1-2": "Celebrity Fan/Gossip", "IAB1-3": "Fine Art", "IAB1-4": "Humor", "IAB1-5": "Movies", "IAB1-6": "Music & Audio", "IAB1-7": "Television & Video" }, "IAB10": { "IAB10": "Home & Garden", "IAB10-1": "Appliances", "IAB10-2": "Entertaining", "IAB10-3": "Environmental Safety", "IAB10-4": "Gardening" } // ... all categories } } ] } ``` ### Error Handling - **202** - Categories being calculated, check back. - **400** - Bad or malformed HTTP request. - **401** - Unauthorized - check your access and secret key. - **402** - Account request limit reached. ``` -------------------------------- ### GET /thumbnails/v2/{base64-url}/info Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Returns metadata about a screenshot as JSON, including the current state, a pre-signed image URL, and the last updated timestamp. ```APIDOC ## GET /thumbnails/v2/{base64-url}/info ### Description Returns metadata about a screenshot as JSON, including the current state, a pre-signed image URL, and the last updated timestamp. ### Method GET ### Endpoint https://api.webshrinker.com/thumbnails/v2/{base64-url}/info ### Parameters #### Path Parameters - **base64-url** (string) - Required - The base64-encoded URL of the website for which the screenshot was taken. #### Query Parameters - **size** (string) - Optional - The size of the screenshot (e.g., 'xlarge'). ### Authentication Basic authentication using access key and secret key. ### Request Example ``` curl -v -u "access-key:secret-key" \ "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==/info" ``` ### Response #### Success Response (200) Returns JSON with metadata including the current state, a pre-signed image URL, and the last updated timestamp. #### Response Example (No explicit response example provided in the source.) ``` -------------------------------- ### Generate Pre-signed URL with Python Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Python function to generate a pre-signed URL for the Website Screenshot API. It uses urlsafe_b64encode and MD5 hashing to create the signed request. The example prints the signed URL for a given URL and size. ```python try: from urllib import urlencode except ImportError: from urllib.parse import urlencode from base64 import urlsafe_b64encode import hashlib def webshrinker_v2(access_key, secret_key, url, params): params['key'] = access_key request = "thumbnails/v2/%s?%s" % (urlsafe_b64encode(url).decode('utf-8'), urlencode(params, True)) signed = hashlib.md5("{}:{}".format(secret_key, request).encode('utf-8')).hexdigest() return "https://api.webshrinker.com/%s&hash=%s" % (request, signed) access_key = "your access key" secret_key = "your secret key" url = b"http://www.example.com" params = {'size': 'xlarge'} print(webshrinker_v2(access_key, secret_key, url, params)) ``` -------------------------------- ### Generate Pre-signed URL with PHP Source: https://docs.webshrinker.com/v2/website-screenshot-api.html PHP function to generate a pre-signed URL for the Website Screenshot API. It builds the request with the access key and options, computes an MD5 hash, and returns the full URL. The example prints the signed URL for a given URL and size. ```php 'xlarge']); echo "$signedUrl\n"; ?> ``` -------------------------------- ### PHP: Generate pre-signed URL and handle screenshot response Source: https://docs.webshrinker.com/v2/website-screenshot-api.html PHP example that constructs a pre-signed URL for the Webshrinker API v2, sends a request, and handles status codes 200, 202, 400, 401, and 402. The code saves the screenshot PNG on success or placeholder on 202. ```php switch($status_code) { case 200: // $image_data contains the screenshot PNG file_put_contents('screenshot.png', $image_data); echo "Screenshot saved to screenshot.png\n"; break; case 202: // Placeholder image returned; screenshot being generated file_put_contents('screenshot.png', $image_data); echo "Screenshot being created, placeholder saved\n"; break; case 400: echo "Bad or malformed HTTP request\n"; break; case 401: echo "Unauthorized - check your access and secret key\n"; break; case 402: echo "Account request limit reached\n"; break; } ``` -------------------------------- ### cURL Request to Balance Endpoint Source: https://docs.webshrinker.com/v1/userinfo-balance-api.html Sends a GET request to the balance endpoint using cURL with Basic authentication and Accept header. Replace 'access-key:secret-key' with your credentials. ```shell curl -u "access-key:secret-key" \ -H "Accept: application/json" \ "https://api.webshrinker.com/userinfo/v1/balance" ``` -------------------------------- ### C# using directives Source: https://docs.webshrinker.com/v3/website-category-api.html Required using directives for the C# example that makes a request to the Website Category API. These namespaces provide the classes used for HTTP requests, encoding, and stream reading. ```csharp using System; using System.Text; using System.Net; using System.IO; ``` -------------------------------- ### GET https://api.webshrinker.com/userinfo/v1/balance Source: https://docs.webshrinker.com/v1/userinfo-balance-api.html Returns the current number of remaining API credits for the billing cycle as a plain integer in the response body. Requires Basic HTTP Authentication. ```APIDOC ## [GET] https://api.webshrinker.com/userinfo/v1/balance ### Description Returns the current number of remaining API credits for the billing cycle as a plain integer in the response body. ### Method GET ### Endpoint https://api.webshrinker.com/userinfo/v1/balance ### Parameters #### Request Headers - **Accept** (string) - Required - Must be `application/json` - **Authorization** (string) - Required - Basic authentication header with base64-encoded access key and secret key ### Request Example ``` curl -u "access-key:secret-key" \ -H "Accept: application/json" \ "https://api.webshrinker.com/userinfo/v1/balance" ``` ### Response #### Success Response (200) - **body** (integer) - The number of remaining API credits for the current billing cycle. #### Response Example ``` 99 ``` #### Error Response (401) - **error.message** (string) - Error description. #### Error Response Example ``` { "error": { "message": "Invalid signed hash or no API key/secret given" } } ``` ### HTTP Status Codes - **200** - OK - Request successful. Balance returned as integer. - **202** - Accepted - Request accepted; processing on server. - **400** - Bad Request - Invalid request parameters. - **401** - Unauthorized - Wrong or missing API credentials. - **402** - Payment Required - Account balance depleted. - **412** - Precondition Failed - Insufficient information to process request. - **429** - Too Many Requests - Rate limit exceeded. - **500** - Internal Server Error - Server error. Retry the request. ``` -------------------------------- ### Image Request with curl Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Example request to the Website Screenshot API using curl with Basic Auth. The URL includes the base64-encoded target URL and a size parameter. The response is saved to screenshot.png. ```shell # aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw== = base64("https://www.webshrinker.com/") curl -v -u "access-key:secret-key" \ "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge" \ -o screenshot.png ``` -------------------------------- ### Base64-encode target URL and authenticate with WebShrinker API Source: https://docs.webshrinker.com/v3/website-category-api.html C# example that base64-encodes the target domain and the API key/secret pair to construct the WebShrinker Categories v3 request URL and Authorization header. Uses ISO-8859-1 encoding for the base64 conversion and prints the JSON response to the console. ```csharp string apiKey = "your access key"; string apiSecret = "your secret key"; string domain = "example.com"; string apiUrl = "https://api.webshrinker.com/categories/v3/" + Convert.ToBase64String( Encoding.GetEncoding("ISO-8859-1").GetBytes(domain)); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl); request.ContentType = "application/json; charset=utf-8"; request.Headers["Authorization"] = "Basic " + Convert.ToBase64String( Encoding.GetEncoding("ISO-8859-1").GetBytes(apiKey + ":" + apiSecret)); request.PreAuthenticate = true; HttpWebResponse resp = request.GetResponse() as HttpWebResponse; using (Stream s = resp.GetResponseStream()) { Console.WriteLine(new StreamReader(s, Encoding.UTF8).ReadToEnd()); } ``` -------------------------------- ### Image Request with PHP and cURL Source: https://docs.webshrinker.com/v2/website-screenshot-api.html PHP example that generates a signed URL and performs an image request using cURL. It sets the URL and return transfer option, then executes the request and retrieves the HTTP status code. The image data is stored in $image_data. ```php 'xlarge']); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $image_data = curl_exec($ch); $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); ``` -------------------------------- ### GET https://api.webshrinker.com/thumbnails/v2/{base64-url} Source: https://docs.webshrinker.com/v2/website-screenshot-api.html The Image Request endpoint captures a browser-rendered screenshot of a website and returns it as a PNG image. It supports multiple sizes and formats, and returns a placeholder image with a 202 status if the screenshot is still being generated. ```APIDOC ## [GET] https://api.webshrinker.com/thumbnails/v2/{base64-url} ### Description Returns the screenshot image directly (PNG). If the screenshot is still being generated, a placeholder image is returned with a 202 Accepted status code. ### Method GET ### Endpoint https://api.webshrinker.com/thumbnails/v2/{base64-url} ### Parameters #### Path Parameters - **base64-url** (string) - Required - The base64-encoded URL of the website to capture. #### Query Parameters - **size** (string) - Optional - The size of the screenshot (e.g., xlarge). - **key** (string) - Required for pre-signed URLs - Your access key. - **hash** (string) - Required for pre-signed URLs - MD5 hash of `secret-key:request-url`. ### Request Example ``` curl -v -u "access-key:secret-key" \ "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge" \ -o screenshot.png ``` ### Response #### Success Response (200) - **image** (PNG) - The screenshot image. #### Response Example ``` [Binary image data] ``` #### Success Response (202) - **placeholder image** (PNG) - A placeholder image indicating the screenshot is still being generated. #### Response Example ``` [Binary placeholder image data] ``` ``` -------------------------------- ### Webshrinker Taxonomy Response (200 OK) Source: https://docs.webshrinker.com/v3/website-category-api.html Example 200 OK response for the WebShrinker taxonomy. Categories contain only `id` and `label` fields, without confidence scores or parent references. ```json { "data": [ { "categories": [ { "id": "business", "label": "Business" }, { "id": "informationtech", "label": "Information Technology" } ], "url": "webshrinker.com" } ] } ``` -------------------------------- ### GET /categories/v3/{base64_url} Source: https://docs.webshrinker.com/v3/website-category-api.html This code snippet documents the Website Category API v3 endpoint for retrieving category information for a given URL. It includes the endpoint structure, authentication, request parameters, response formats for both IAB and Webshrinker taxonomies, and error handling. ```APIDOC ## [GET] /categories/v3/{base64_url} ### Description Retrieves website category information for a given domain using the Website Category API v3. The target URL must be Base64-encoded and included as a path parameter. ### Method GET ### Endpoint https://api.webshrinker.com/categories/v3/{base64_url} ### Parameters #### Path Parameters - **base64_url** (string) - Required - The Base64-encoded target URL (e.g., domain name) to categorize. #### Authentication - **Authorization** (string) - Required - Basic authentication header using the API key and secret. Format: `Basic base64(apiKey:apiSecret)`. ### Request Example ``` GET /categories/v3/ZXhhbXBsZS5jb20= HTTP/1.1 Host: api.webshrinker.com Authorization: Basic base64(apiKey:apiSecret) ``` ### Response #### Success Response (200) - IAB Taxonomy - **data** (array) - Array of category results. - **url** (string) - The URL that was categorized. - **categories** (array) - Array of category objects. - **confident** (boolean) - True if the majority of content relates to this category. - **id** (string) - IAB category identifier (e.g., `IAB19-18`). - **label** (string) - Human-readable category name. - **parent** (string) - Parent category identifier. - **score** (string) - Floating-point confidence value (0.0 – 1.0). #### Response Example (IAB Taxonomy) ```json { "data": [ { "categories": [ { "confident": true, "id": "IAB19", "label": "Technology & Computing", "parent": "IAB19", "score": "0.855809166500086094" }, { "confident": true, "id": "IAB19-18", "label": "Internet Technology", "parent": "IAB19", "score": "0.824063117153139624" } ], "url": "webshrinker.com" } ] } ``` #### Success Response (200) - Webshrinker Taxonomy - **data** (array) - Array of category results. - **url** (string) - The URL that was categorized. - **categories** (array) - Array of category objects. - **id** (string) - Category identifier (e.g., `business`). - **label** (string) - Human-readable category name. #### Response Example (Webshrinker Taxonomy) ```json { "data": [ { "categories": [ { "id": "business", "label": "Business" }, { "id": "informationtech", "label": "Information Technology" } ], "url": "webshrinker.com" } ] } ``` #### Error Response (401 Unauthorized) - **error** (object) - Error details. - **message** (string) - Error message. #### Error Response Example ```json { "error": { "message": "Invalid signed hash or no API key/secret given" } } ``` ### HTTP Status Codes - **200** - OK - Current categories returned successfully. - **202** - Accepted - Categories are being calculated. May include partial data – check back shortly. - **400** - Bad Request - Malformed or invalid HTTP request. - **401** - Unauthorized - Invalid API credentials or signature. - **402** - Payment Required - Account request limit reached. - **412** - Precondition Failed - Insufficient information to classify the target URL. - **429** - Too Many Requests - Rate limit exceeded. Reduce request frequency. - **500** - Server Error - Internal error. Retry the request. ``` -------------------------------- ### Error Response JSON Source: https://docs.webshrinker.com/v1/userinfo-balance-api.html Example error response body with a JSON object containing an error message. ```json { "error": { "message": "Invalid signed hash or no API key/secret given" } } ``` -------------------------------- ### GET /categories/v3 Source: https://docs.webshrinker.com/v3/website-category-api.html Classify a URL, domain, or IP address into categories. Requires authentication via Basic HTTP Authentication or Pre-signed URLs. ```APIDOC ## GET /categories/v3 ### Description Classify any URL, domain name, or IP address into industry-standard categories using machine learning. Supports both the IAB Tech Lab taxonomy (400+ categories) and Webshrinker's own 40-category taxonomy. ### Method GET ### Endpoint https://api.webshrinker.com/categories/v3/{url_or_domain_or_ip} ### Authentication Basic HTTP Authentication: Encode your access key and secret key as `access-key:secret-key` in base64 and pass it in the `Authorization` header. Always use HTTPS. Pre-signed URLs: The URL is signed using an MD5 hash of `secret-key:request-path-with-params`. Optionally include an `expires` Unix timestamp to limit URL validity. ### Request Example ``` curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3/d2Vic2hyaW5rZXIuY29t" ``` ### Response #### Success Response Returns category data for the requested URL, domain, or IP address. #### Response Example (No explicit response example provided in the source.) ``` -------------------------------- ### GET /categories/v3 Source: https://docs.webshrinker.com/v3/website-category-api.html Retrieve the complete set of available categories for a given taxonomy. Useful for building category filters or understanding the classification space. ```APIDOC ## GET /categories/v3 ### Description Retrieve the complete set of available categories for a given taxonomy. Useful for building category filters or understanding the classification space. ### Method GET ### Endpoint https://api.webshrinker.com/categories/v3 ### Parameters #### Query Parameters - **key** (string) - Required* - Your access key. Required only when using pre-signed URLs. - **expires** (integer) - Optional - Unix timestamp after which the pre-signed URL expires. - **taxonomy** (string) - Optional - Taxonomy to use: `iabv1` or `webshrinker`. Default: `iabv1`. - **_`** (string) - Optional - Cache buster — any value to bypass CDN caching. ### Request Example ``` # Using Basic Authentication curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3" # Using a pre-signed URL curl "https://api.webshrinker.com/categories/v3/?key=TvQu6ARhl2Zs7BVV1plU&hash=0f41d9264f05b2aeb0064fc6d7114cbc" ``` ### Response #### Success Response (200) - **response** (object) - The response body containing the list of categories. #### Response Example ```json { "response": { "categories": [] } } ``` ``` -------------------------------- ### C# request with Basic Authentication Source: https://docs.webshrinker.com/v3/website-category-api.html Shows how to make a request to the Website Category API using Basic Authentication with a Base64-encoded API key and secret. The response is read and printed to the console. ```csharp HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl); request.ContentType = "application/json; charset=utf-8"; request.Headers["Authorization"] = "Basic " + Convert.ToBase64String( Encoding.GetEncoding("ISO-8859-1").GetBytes(apiKey + ":" + apiSecret)); request.PreAuthenticate = true; HttpWebResponse resp = request.GetResponse() as HttpWebResponse; using (Stream s = resp.GetResponseStream()) { var reader = new StreamReader(s, Encoding.UTF8); Console.WriteLine(reader.ReadToEnd()); } ``` -------------------------------- ### Generate Pre-signed URL with Shell Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Generates a pre-signed URL for the Website Screenshot API using shell commands. It base64-encodes the URL, constructs the request, and computes an MD5 hash of the secret key and request. The final URL is printed to stdout. ```shell WS_ACCESS_KEY="your access key" WS_SECRET_KEY="your secret key" URL=$(echo -n "http://www.example.com" | base64) REQUEST="thumbnails/v2/$URL?key=$WS_ACCESS_KEY&size=xlarge" HASH=$(echo -n "$WS_SECRET_KEY:$REQUEST" | (md5sum || md5)) echo "https://api.webshrinker.com/$REQUEST&hash=$HASH" ``` -------------------------------- ### Generate pre-signed URL with shell Source: https://docs.webshrinker.com/v3/website-category-api.html Constructs a pre-signed URL for the Website Category API v3 by base64-encoding the target URL, building the request string, and computing an MD5 hash of the secret key and request. The final URL is printed to stdout. ```shell URL=$(echo -n "https://www.webshrinker.com" | base64) REQUEST="categories/v3/$URL?key=$WS_ACCESS_KEY" HASH=$(echo -n "$WS_SECRET_KEY:$REQUEST" | (md5sum || md5)) echo "https://api.webshrinker.com/$REQUEST&hash=$HASH" ``` -------------------------------- ### Basic Auth Image Request with curl Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Use this curl command to request a screenshot with Basic HTTP Authentication. Replace access-key and secret-key with your credentials. The response is saved to screenshot.png. ```shell # Image request with Basic Auth curl -v -u "access-key:secret-key" \ "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==?size=xlarge" \ -o screenshot.png ``` -------------------------------- ### Info Request with curl Source: https://docs.webshrinker.com/v2/website-screenshot-api.html Use this curl command to request metadata about a screenshot. Replace 'access-key' and 'secret-key' with your credentials and the base64-encoded URL in the path. ```Shell curl -v -u "access-key:secret-key" \ "https://api.webshrinker.com/thumbnails/v2/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29tLw==/info" ``` -------------------------------- ### GET /categories/v3/{url} Source: https://docs.webshrinker.com/v3/website-category-api.html Categorize a specific URL. The URL must be base64-encoded and passed as a path parameter. Supports two taxonomies via the `taxonomy` query parameter. ```APIDOC ## GET /categories/v3/{url} ### Description Categorize a specific URL. The URL must be base64-encoded and passed as a path parameter. Supports two taxonomies via the `taxonomy` query parameter. ### Method GET ### Endpoint https://api.webshrinker.com/categories/v3/{url} ### Parameters #### Path Parameters - **url** (string) - Required - The base64-encoded URL to categorize. #### Query Parameters - **key** (string) - Required* - Your access key. Required only when using pre-signed URLs. - **expires** (integer) - Optional - Unix timestamp after which the pre-signed URL expires. - **taxonomy** (string) - Optional - Taxonomy to use: `iabv1` or `webshrinker`. Default: `iabv1`. - **_`** (string) - Optional - Cache buster — any value to bypass CDN caching. ### Request Example ``` # Using Basic Authentication curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29t" # Using a pre-signed URL curl "https://api.webshrinker.com/categories/v3/aHR0cHM6Ly93d3cud2Vic2hyaW5rZXIuY29t?key=TvQu6ARhl2Zs7BVV1plU&hash=0f41d9264f05b2aeb0064fc6d7114cbc" ``` ### Response #### Success Response (200) - **response** (object) - The response body containing the categorization results. #### Response Example ```json { "response": { "categories": [] } } ``` ``` -------------------------------- ### curl request with Basic Auth and pre-signed URL Source: https://docs.webshrinker.com/v3/website-category-api.html Shows how to call the Category Lookup endpoint using curl with either Basic Authentication or a pre-signed URL. The target URL must be Base64-encoded before appending to the endpoint path. ```shell # d2Vic2hyaW5rZXIuY29t = base64("webshrinker.com") # Basic Authentication curl -u "access-key:secret-key" \ "https://api.webshrinker.com/categories/v3/d2Vic2hyaW5rZXIuY29t" # Pre-signed URL curl "https://api.webshrinker.com/categories/v3/d2Vic2hyaW5rZXIuY29t?key=TvQu6ARhl2Zs7BVV1plU&hash=afe42ba2e8ae6f9d5ec2a0535ab484fe" ```