SauceNAO
Classes
SauceNAO
Bases: BaseSearchEngine[SauceNAOResponse]
API client for the SauceNAO image search engine.
Used for performing reverse image searches using SauceNAO service.
Attributes:
Name | Type | Description |
---|---|---|
base_url |
str
|
The base URL for SauceNAO searches. |
params |
dict[str, Any]
|
The query parameters for SauceNAO search. |
Source code in PicImageSearch/engines/saucenao.py
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
Attributes
params = self.params.add('dbs[]', i)
instance-attribute
Functions
__init__(base_url='https://saucenao.com', api_key=None, numres=5, hide=0, minsim=30, output_type=2, testmode=0, dbmask=None, dbmaski=None, db=999, dbs=None, **request_kwargs)
Initializes a SauceNAO API client with specified configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL for SauceNAO searches, defaults to 'https://saucenao.com'. |
'https://saucenao.com'
|
api_key
|
Optional[str]
|
API key for SauceNAO API access, required for full API functionality. |
None
|
numres
|
int
|
Number of results to return (1-40), defaults to 5. |
5
|
hide
|
int
|
Content filtering level (0-3), defaults to 0. 0: Show all results 1: Hide expected explicit results 2: Hide expected questionable results 3: Hide all but expected safe results |
0
|
minsim
|
int
|
Minimum similarity percentage for results (0-100), defaults to 30. |
30
|
output_type
|
int
|
Output format of search results, defaults to 2. 0: HTML 1: XML 2: JSON |
2
|
testmode
|
int
|
If 1, performs a dry-run search without using search quota. |
0
|
dbmask
|
Optional[int]
|
Bitmask for enabling specific databases. |
None
|
dbmaski
|
Optional[int]
|
Bitmask for disabling specific databases. |
None
|
db
|
int
|
Database index to search from (0-999), defaults to 999 (all databases). |
999
|
dbs
|
Optional[list[int]]
|
List of specific database indices to search from. |
None
|
**request_kwargs
|
Any
|
Additional arguments passed to the HTTP client. |
{}
|
Note
- API documentation: https://saucenao.com/user.php?page=search-api
- Database indices: https://saucenao.com/tools/examples/api/index_details.txt
- Using API key is recommended to avoid rate limits and access more features.
- When
dbs
is provided, it takes precedence overdb
parameter.
Source code in PicImageSearch/engines/saucenao.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
search(url=None, file=None, **kwargs)
async
Performs a reverse image search on SauceNAO.
This method supports two ways of searching
- Search by image URL
- Search by uploading a local image file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
Optional[str]
|
URL of the image to search. |
None
|
file
|
Union[str, bytes, Path, None]
|
Local image file, can be a path string, bytes data, or Path object. |
None
|
**kwargs
|
Any
|
Additional arguments passed to the parent class. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
SauceNAOResponse |
SauceNAOResponse
|
An object containing: - Search results with similarity scores - Source information and thumbnails - Additional metadata (status code, search quotas) |
Raises:
Type | Description |
---|---|
ValueError
|
If neither |
Note
- Only one of
url
orfile
should be provided. - API limits vary based on account type and API key usage.
- Free accounts are limited to:
- 150 searches per day
- 4 searches per 30 seconds
- Results are sorted by similarity score in descending order.
Source code in PicImageSearch/engines/saucenao.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|