@spyglasshq/sdk 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -2
  3. package/dist/cjs/BaseClient.d.ts +54 -0
  4. package/dist/cjs/BaseClient.js +77 -0
  5. package/dist/cjs/Client.d.ts +32 -0
  6. package/dist/cjs/Client.js +93 -0
  7. package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
  8. package/dist/cjs/api/errors/BadRequestError.js +54 -0
  9. package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
  10. package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
  11. package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
  12. package/dist/cjs/api/errors/ForbiddenError.js +54 -0
  13. package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
  14. package/dist/cjs/api/errors/InternalServerError.js +54 -0
  15. package/dist/cjs/api/errors/MethodNotAllowedError.d.ts +7 -0
  16. package/dist/cjs/api/errors/MethodNotAllowedError.js +54 -0
  17. package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
  18. package/dist/cjs/api/errors/NotFoundError.js +54 -0
  19. package/dist/cjs/api/errors/PaymentRequiredError.d.ts +7 -0
  20. package/dist/cjs/api/errors/PaymentRequiredError.js +54 -0
  21. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
  22. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  23. package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
  24. package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
  25. package/dist/cjs/api/errors/index.d.ts +9 -0
  26. package/dist/cjs/api/errors/index.js +25 -0
  27. package/dist/cjs/api/index.d.ts +3 -0
  28. package/dist/cjs/api/index.js +19 -0
  29. package/dist/cjs/api/resources/account/client/Client.d.ts +42 -0
  30. package/dist/cjs/api/resources/account/client/Client.js +135 -0
  31. package/dist/cjs/api/resources/account/client/index.d.ts +1 -0
  32. package/dist/cjs/api/resources/account/client/index.js +2 -0
  33. package/dist/cjs/api/resources/account/exports.d.ts +2 -0
  34. package/dist/cjs/api/resources/account/exports.js +21 -0
  35. package/dist/cjs/api/resources/account/index.d.ts +2 -0
  36. package/dist/cjs/api/resources/account/index.js +18 -0
  37. package/dist/cjs/api/resources/account/types/GetCreditUsageResponse.d.ts +10 -0
  38. package/dist/cjs/api/resources/account/types/GetCreditUsageResponse.js +3 -0
  39. package/dist/cjs/api/resources/account/types/index.d.ts +1 -0
  40. package/dist/cjs/api/resources/account/types/index.js +17 -0
  41. package/dist/cjs/api/resources/index.d.ts +8 -0
  42. package/dist/cjs/api/resources/index.js +47 -0
  43. package/dist/cjs/api/resources/indexing/client/Client.d.ts +74 -0
  44. package/dist/cjs/api/resources/indexing/client/Client.js +219 -0
  45. package/dist/cjs/api/resources/indexing/client/index.d.ts +1 -0
  46. package/dist/cjs/api/resources/indexing/client/index.js +17 -0
  47. package/dist/cjs/api/resources/indexing/client/requests/IndexBrandRequest.d.ts +9 -0
  48. package/dist/cjs/api/resources/indexing/client/requests/IndexBrandRequest.js +3 -0
  49. package/dist/cjs/api/resources/indexing/client/requests/IndexBrandStatusRequest.d.ts +10 -0
  50. package/dist/cjs/api/resources/indexing/client/requests/IndexBrandStatusRequest.js +3 -0
  51. package/dist/cjs/api/resources/indexing/client/requests/index.d.ts +2 -0
  52. package/dist/cjs/api/resources/indexing/client/requests/index.js +2 -0
  53. package/dist/cjs/api/resources/indexing/exports.d.ts +2 -0
  54. package/dist/cjs/api/resources/indexing/exports.js +21 -0
  55. package/dist/cjs/api/resources/indexing/index.d.ts +2 -0
  56. package/dist/cjs/api/resources/indexing/index.js +18 -0
  57. package/dist/cjs/api/resources/indexing/types/IndexBrandResponse.d.ts +11 -0
  58. package/dist/cjs/api/resources/indexing/types/IndexBrandResponse.js +11 -0
  59. package/dist/cjs/api/resources/indexing/types/IndexBrandStatusResponse.d.ts +10 -0
  60. package/dist/cjs/api/resources/indexing/types/IndexBrandStatusResponse.js +11 -0
  61. package/dist/cjs/api/resources/indexing/types/index.d.ts +2 -0
  62. package/dist/cjs/api/resources/indexing/types/index.js +18 -0
  63. package/dist/cjs/api/resources/search/client/Client.d.ts +333 -0
  64. package/dist/cjs/api/resources/search/client/Client.js +819 -0
  65. package/dist/cjs/api/resources/search/client/index.d.ts +1 -0
  66. package/dist/cjs/api/resources/search/client/index.js +17 -0
  67. package/dist/cjs/api/resources/search/client/requests/GetAccountRequest.d.ts +10 -0
  68. package/dist/cjs/api/resources/search/client/requests/GetAccountRequest.js +3 -0
  69. package/dist/cjs/api/resources/search/client/requests/GetBrandLandingPagesRequest.d.ts +13 -0
  70. package/dist/cjs/api/resources/search/client/requests/GetBrandLandingPagesRequest.js +3 -0
  71. package/dist/cjs/api/resources/search/client/requests/GetBrandMediaInsightsRequest.d.ts +15 -0
  72. package/dist/cjs/api/resources/search/client/requests/GetBrandMediaInsightsRequest.js +3 -0
  73. package/dist/cjs/api/resources/search/client/requests/GetCommentsRequest.d.ts +16 -0
  74. package/dist/cjs/api/resources/search/client/requests/GetCommentsRequest.js +3 -0
  75. package/dist/cjs/api/resources/search/client/requests/GetMediaRequest.d.ts +313 -0
  76. package/dist/cjs/api/resources/search/client/requests/GetMediaRequest.js +268 -0
  77. package/dist/cjs/api/resources/search/client/requests/SearchBrandsRequest.d.ts +39 -0
  78. package/dist/cjs/api/resources/search/client/requests/SearchBrandsRequest.js +15 -0
  79. package/dist/cjs/api/resources/search/client/requests/SearchCreatorsRequest.d.ts +223 -0
  80. package/dist/cjs/api/resources/search/client/requests/SearchCreatorsRequest.js +191 -0
  81. package/dist/cjs/api/resources/search/client/requests/SearchTaxonomiesRequest.d.ts +10 -0
  82. package/dist/cjs/api/resources/search/client/requests/SearchTaxonomiesRequest.js +3 -0
  83. package/dist/cjs/api/resources/search/client/requests/index.d.ts +8 -0
  84. package/dist/cjs/api/resources/search/client/requests/index.js +9 -0
  85. package/dist/cjs/api/resources/search/exports.d.ts +2 -0
  86. package/dist/cjs/api/resources/search/exports.js +21 -0
  87. package/dist/cjs/api/resources/search/index.d.ts +2 -0
  88. package/dist/cjs/api/resources/search/index.js +18 -0
  89. package/dist/cjs/api/resources/search/types/GetAccountResponse.d.ts +43 -0
  90. package/dist/cjs/api/resources/search/types/GetAccountResponse.js +3 -0
  91. package/dist/cjs/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.d.ts +5 -0
  92. package/dist/cjs/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.js +8 -0
  93. package/dist/cjs/api/resources/search/types/GetBrandLandingPagesResponse.d.ts +13 -0
  94. package/dist/cjs/api/resources/search/types/GetBrandLandingPagesResponse.js +3 -0
  95. package/dist/cjs/api/resources/search/types/GetBrandMediaInsightsRequestType.d.ts +7 -0
  96. package/dist/cjs/api/resources/search/types/GetBrandMediaInsightsRequestType.js +10 -0
  97. package/dist/cjs/api/resources/search/types/GetBrandMediaInsightsResponse.d.ts +27 -0
  98. package/dist/cjs/api/resources/search/types/GetBrandMediaInsightsResponse.js +3 -0
  99. package/dist/cjs/api/resources/search/types/GetCommentsResponse.d.ts +31 -0
  100. package/dist/cjs/api/resources/search/types/GetCommentsResponse.js +3 -0
  101. package/dist/cjs/api/resources/search/types/GetMediaResponse.d.ts +110 -0
  102. package/dist/cjs/api/resources/search/types/GetMediaResponse.js +57 -0
  103. package/dist/cjs/api/resources/search/types/SearchBrandsResponse.d.ts +35 -0
  104. package/dist/cjs/api/resources/search/types/SearchBrandsResponse.js +16 -0
  105. package/dist/cjs/api/resources/search/types/SearchCreatorsResponse.d.ts +36 -0
  106. package/dist/cjs/api/resources/search/types/SearchCreatorsResponse.js +16 -0
  107. package/dist/cjs/api/resources/search/types/SearchTaxonomiesResponse.d.ts +4 -0
  108. package/dist/cjs/api/resources/search/types/SearchTaxonomiesResponse.js +3 -0
  109. package/dist/cjs/api/resources/search/types/index.d.ts +10 -0
  110. package/dist/cjs/api/resources/search/types/index.js +26 -0
  111. package/dist/cjs/api/types/Error_.d.ts +33 -0
  112. package/dist/cjs/api/types/Error_.js +23 -0
  113. package/dist/cjs/api/types/index.d.ts +1 -0
  114. package/dist/cjs/api/types/index.js +17 -0
  115. package/dist/cjs/auth/BearerAuthProvider.d.ts +20 -0
  116. package/dist/cjs/auth/BearerAuthProvider.js +79 -0
  117. package/dist/cjs/auth/index.d.ts +1 -0
  118. package/dist/cjs/auth/index.js +5 -0
  119. package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
  120. package/dist/cjs/core/auth/AuthProvider.js +9 -0
  121. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  122. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  123. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  124. package/dist/cjs/core/auth/BasicAuth.js +33 -0
  125. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  126. package/dist/cjs/core/auth/BearerToken.js +16 -0
  127. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  128. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  129. package/dist/cjs/core/auth/index.d.ts +5 -0
  130. package/dist/cjs/core/auth/index.js +11 -0
  131. package/dist/cjs/core/base64.d.ts +2 -0
  132. package/dist/cjs/core/base64.js +26 -0
  133. package/dist/cjs/core/exports.d.ts +1 -0
  134. package/dist/cjs/core/exports.js +17 -0
  135. package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
  136. package/dist/cjs/core/fetcher/APIResponse.js +2 -0
  137. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
  138. package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
  139. package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
  140. package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
  141. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
  142. package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
  143. package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
  144. package/dist/cjs/core/fetcher/Fetcher.js +274 -0
  145. package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
  146. package/dist/cjs/core/fetcher/Headers.js +84 -0
  147. package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
  148. package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
  149. package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
  150. package/dist/cjs/core/fetcher/RawResponse.js +44 -0
  151. package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
  152. package/dist/cjs/core/fetcher/Supplier.js +22 -0
  153. package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
  154. package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
  155. package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
  156. package/dist/cjs/core/fetcher/getErrorResponseBody.js +58 -0
  157. package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
  158. package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
  159. package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
  160. package/dist/cjs/core/fetcher/getHeader.js +11 -0
  161. package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
  162. package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
  163. package/dist/cjs/core/fetcher/getResponseBody.d.ts +17 -0
  164. package/dist/cjs/core/fetcher/getResponseBody.js +85 -0
  165. package/dist/cjs/core/fetcher/index.d.ts +13 -0
  166. package/dist/cjs/core/fetcher/index.js +19 -0
  167. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  168. package/dist/cjs/core/fetcher/makePassthroughRequest.js +173 -0
  169. package/dist/cjs/core/fetcher/makeRequest.d.ts +11 -0
  170. package/dist/cjs/core/fetcher/makeRequest.js +94 -0
  171. package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
  172. package/dist/cjs/core/fetcher/redactUrl.js +88 -0
  173. package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
  174. package/dist/cjs/core/fetcher/requestWithRetries.js +91 -0
  175. package/dist/cjs/core/fetcher/signals.d.ts +6 -0
  176. package/dist/cjs/core/fetcher/signals.js +33 -0
  177. package/dist/cjs/core/headers.d.ts +2 -0
  178. package/dist/cjs/core/headers.js +31 -0
  179. package/dist/cjs/core/index.d.ts +6 -0
  180. package/dist/cjs/core/index.js +45 -0
  181. package/dist/cjs/core/json.d.ts +15 -0
  182. package/dist/cjs/core/json.js +24 -0
  183. package/dist/cjs/core/logging/exports.d.ts +18 -0
  184. package/dist/cjs/core/logging/exports.js +45 -0
  185. package/dist/cjs/core/logging/index.d.ts +1 -0
  186. package/dist/cjs/core/logging/index.js +17 -0
  187. package/dist/cjs/core/logging/logger.d.ts +126 -0
  188. package/dist/cjs/core/logging/logger.js +144 -0
  189. package/dist/cjs/core/requestBody.d.ts +12 -0
  190. package/dist/cjs/core/requestBody.js +26 -0
  191. package/dist/cjs/core/runtime/index.d.ts +1 -0
  192. package/dist/cjs/core/runtime/index.js +6 -0
  193. package/dist/cjs/core/runtime/runtime.d.ts +28 -0
  194. package/dist/cjs/core/runtime/runtime.js +176 -0
  195. package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
  196. package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
  197. package/dist/cjs/core/url/encodePathParam.d.ts +3 -0
  198. package/dist/cjs/core/url/encodePathParam.js +27 -0
  199. package/dist/cjs/core/url/index.d.ts +4 -0
  200. package/dist/cjs/core/url/index.js +11 -0
  201. package/dist/cjs/core/url/join.d.ts +1 -0
  202. package/dist/cjs/core/url/join.js +68 -0
  203. package/dist/cjs/core/url/qs.d.ts +7 -0
  204. package/dist/cjs/core/url/qs.js +76 -0
  205. package/dist/cjs/environments.d.ts +4 -0
  206. package/dist/cjs/environments.js +7 -0
  207. package/dist/cjs/errors/SpyglassError.d.ts +15 -0
  208. package/dist/cjs/errors/SpyglassError.js +53 -0
  209. package/dist/cjs/errors/SpyglassTimeoutError.d.ts +6 -0
  210. package/dist/cjs/errors/SpyglassTimeoutError.js +52 -0
  211. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  212. package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
  213. package/dist/cjs/errors/index.d.ts +2 -0
  214. package/dist/cjs/errors/index.js +7 -0
  215. package/dist/cjs/exports.d.ts +1 -0
  216. package/dist/cjs/exports.js +17 -0
  217. package/dist/cjs/index.d.ts +6 -0
  218. package/dist/cjs/index.js +48 -0
  219. package/dist/cjs/version.d.ts +1 -0
  220. package/dist/cjs/version.js +4 -0
  221. package/dist/esm/BaseClient.d.mts +54 -0
  222. package/dist/esm/BaseClient.mjs +40 -0
  223. package/dist/esm/Client.d.mts +32 -0
  224. package/dist/esm/Client.mjs +56 -0
  225. package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
  226. package/dist/esm/api/errors/BadRequestError.mjs +17 -0
  227. package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
  228. package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
  229. package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
  230. package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
  231. package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
  232. package/dist/esm/api/errors/InternalServerError.mjs +17 -0
  233. package/dist/esm/api/errors/MethodNotAllowedError.d.mts +7 -0
  234. package/dist/esm/api/errors/MethodNotAllowedError.mjs +17 -0
  235. package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
  236. package/dist/esm/api/errors/NotFoundError.mjs +17 -0
  237. package/dist/esm/api/errors/PaymentRequiredError.d.mts +7 -0
  238. package/dist/esm/api/errors/PaymentRequiredError.mjs +17 -0
  239. package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
  240. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  241. package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
  242. package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
  243. package/dist/esm/api/errors/index.d.mts +9 -0
  244. package/dist/esm/api/errors/index.mjs +9 -0
  245. package/dist/esm/api/index.d.mts +3 -0
  246. package/dist/esm/api/index.mjs +3 -0
  247. package/dist/esm/api/resources/account/client/Client.d.mts +42 -0
  248. package/dist/esm/api/resources/account/client/Client.mjs +98 -0
  249. package/dist/esm/api/resources/account/client/index.d.mts +1 -0
  250. package/dist/esm/api/resources/account/client/index.mjs +1 -0
  251. package/dist/esm/api/resources/account/exports.d.mts +2 -0
  252. package/dist/esm/api/resources/account/exports.mjs +3 -0
  253. package/dist/esm/api/resources/account/index.d.mts +2 -0
  254. package/dist/esm/api/resources/account/index.mjs +2 -0
  255. package/dist/esm/api/resources/account/types/GetCreditUsageResponse.d.mts +10 -0
  256. package/dist/esm/api/resources/account/types/GetCreditUsageResponse.mjs +2 -0
  257. package/dist/esm/api/resources/account/types/index.d.mts +1 -0
  258. package/dist/esm/api/resources/account/types/index.mjs +1 -0
  259. package/dist/esm/api/resources/index.d.mts +8 -0
  260. package/dist/esm/api/resources/index.mjs +8 -0
  261. package/dist/esm/api/resources/indexing/client/Client.d.mts +74 -0
  262. package/dist/esm/api/resources/indexing/client/Client.mjs +182 -0
  263. package/dist/esm/api/resources/indexing/client/index.d.mts +1 -0
  264. package/dist/esm/api/resources/indexing/client/index.mjs +1 -0
  265. package/dist/esm/api/resources/indexing/client/requests/IndexBrandRequest.d.mts +9 -0
  266. package/dist/esm/api/resources/indexing/client/requests/IndexBrandRequest.mjs +2 -0
  267. package/dist/esm/api/resources/indexing/client/requests/IndexBrandStatusRequest.d.mts +10 -0
  268. package/dist/esm/api/resources/indexing/client/requests/IndexBrandStatusRequest.mjs +2 -0
  269. package/dist/esm/api/resources/indexing/client/requests/index.d.mts +2 -0
  270. package/dist/esm/api/resources/indexing/client/requests/index.mjs +1 -0
  271. package/dist/esm/api/resources/indexing/exports.d.mts +2 -0
  272. package/dist/esm/api/resources/indexing/exports.mjs +3 -0
  273. package/dist/esm/api/resources/indexing/index.d.mts +2 -0
  274. package/dist/esm/api/resources/indexing/index.mjs +2 -0
  275. package/dist/esm/api/resources/indexing/types/IndexBrandResponse.d.mts +11 -0
  276. package/dist/esm/api/resources/indexing/types/IndexBrandResponse.mjs +8 -0
  277. package/dist/esm/api/resources/indexing/types/IndexBrandStatusResponse.d.mts +10 -0
  278. package/dist/esm/api/resources/indexing/types/IndexBrandStatusResponse.mjs +8 -0
  279. package/dist/esm/api/resources/indexing/types/index.d.mts +2 -0
  280. package/dist/esm/api/resources/indexing/types/index.mjs +2 -0
  281. package/dist/esm/api/resources/search/client/Client.d.mts +333 -0
  282. package/dist/esm/api/resources/search/client/Client.mjs +782 -0
  283. package/dist/esm/api/resources/search/client/index.d.mts +1 -0
  284. package/dist/esm/api/resources/search/client/index.mjs +1 -0
  285. package/dist/esm/api/resources/search/client/requests/GetAccountRequest.d.mts +10 -0
  286. package/dist/esm/api/resources/search/client/requests/GetAccountRequest.mjs +2 -0
  287. package/dist/esm/api/resources/search/client/requests/GetBrandLandingPagesRequest.d.mts +13 -0
  288. package/dist/esm/api/resources/search/client/requests/GetBrandLandingPagesRequest.mjs +2 -0
  289. package/dist/esm/api/resources/search/client/requests/GetBrandMediaInsightsRequest.d.mts +15 -0
  290. package/dist/esm/api/resources/search/client/requests/GetBrandMediaInsightsRequest.mjs +2 -0
  291. package/dist/esm/api/resources/search/client/requests/GetCommentsRequest.d.mts +16 -0
  292. package/dist/esm/api/resources/search/client/requests/GetCommentsRequest.mjs +2 -0
  293. package/dist/esm/api/resources/search/client/requests/GetMediaRequest.d.mts +313 -0
  294. package/dist/esm/api/resources/search/client/requests/GetMediaRequest.mjs +265 -0
  295. package/dist/esm/api/resources/search/client/requests/SearchBrandsRequest.d.mts +39 -0
  296. package/dist/esm/api/resources/search/client/requests/SearchBrandsRequest.mjs +12 -0
  297. package/dist/esm/api/resources/search/client/requests/SearchCreatorsRequest.d.mts +223 -0
  298. package/dist/esm/api/resources/search/client/requests/SearchCreatorsRequest.mjs +188 -0
  299. package/dist/esm/api/resources/search/client/requests/SearchTaxonomiesRequest.d.mts +10 -0
  300. package/dist/esm/api/resources/search/client/requests/SearchTaxonomiesRequest.mjs +2 -0
  301. package/dist/esm/api/resources/search/client/requests/index.d.mts +8 -0
  302. package/dist/esm/api/resources/search/client/requests/index.mjs +3 -0
  303. package/dist/esm/api/resources/search/exports.d.mts +2 -0
  304. package/dist/esm/api/resources/search/exports.mjs +3 -0
  305. package/dist/esm/api/resources/search/index.d.mts +2 -0
  306. package/dist/esm/api/resources/search/index.mjs +2 -0
  307. package/dist/esm/api/resources/search/types/GetAccountResponse.d.mts +43 -0
  308. package/dist/esm/api/resources/search/types/GetAccountResponse.mjs +2 -0
  309. package/dist/esm/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.d.mts +5 -0
  310. package/dist/esm/api/resources/search/types/GetBrandLandingPagesRequestShowInactive.mjs +5 -0
  311. package/dist/esm/api/resources/search/types/GetBrandLandingPagesResponse.d.mts +13 -0
  312. package/dist/esm/api/resources/search/types/GetBrandLandingPagesResponse.mjs +2 -0
  313. package/dist/esm/api/resources/search/types/GetBrandMediaInsightsRequestType.d.mts +7 -0
  314. package/dist/esm/api/resources/search/types/GetBrandMediaInsightsRequestType.mjs +7 -0
  315. package/dist/esm/api/resources/search/types/GetBrandMediaInsightsResponse.d.mts +27 -0
  316. package/dist/esm/api/resources/search/types/GetBrandMediaInsightsResponse.mjs +2 -0
  317. package/dist/esm/api/resources/search/types/GetCommentsResponse.d.mts +31 -0
  318. package/dist/esm/api/resources/search/types/GetCommentsResponse.mjs +2 -0
  319. package/dist/esm/api/resources/search/types/GetMediaResponse.d.mts +110 -0
  320. package/dist/esm/api/resources/search/types/GetMediaResponse.mjs +54 -0
  321. package/dist/esm/api/resources/search/types/SearchBrandsResponse.d.mts +35 -0
  322. package/dist/esm/api/resources/search/types/SearchBrandsResponse.mjs +13 -0
  323. package/dist/esm/api/resources/search/types/SearchCreatorsResponse.d.mts +36 -0
  324. package/dist/esm/api/resources/search/types/SearchCreatorsResponse.mjs +13 -0
  325. package/dist/esm/api/resources/search/types/SearchTaxonomiesResponse.d.mts +4 -0
  326. package/dist/esm/api/resources/search/types/SearchTaxonomiesResponse.mjs +2 -0
  327. package/dist/esm/api/resources/search/types/index.d.mts +10 -0
  328. package/dist/esm/api/resources/search/types/index.mjs +10 -0
  329. package/dist/esm/api/types/Error_.d.mts +33 -0
  330. package/dist/esm/api/types/Error_.mjs +20 -0
  331. package/dist/esm/api/types/index.d.mts +1 -0
  332. package/dist/esm/api/types/index.mjs +1 -0
  333. package/dist/esm/auth/BearerAuthProvider.d.mts +20 -0
  334. package/dist/esm/auth/BearerAuthProvider.mjs +42 -0
  335. package/dist/esm/auth/index.d.mts +1 -0
  336. package/dist/esm/auth/index.mjs +1 -0
  337. package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
  338. package/dist/esm/core/auth/AuthProvider.mjs +6 -0
  339. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  340. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  341. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  342. package/dist/esm/core/auth/BasicAuth.mjs +30 -0
  343. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  344. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  345. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  346. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  347. package/dist/esm/core/auth/index.d.mts +5 -0
  348. package/dist/esm/core/auth/index.mjs +4 -0
  349. package/dist/esm/core/base64.d.mts +2 -0
  350. package/dist/esm/core/base64.mjs +22 -0
  351. package/dist/esm/core/exports.d.mts +1 -0
  352. package/dist/esm/core/exports.mjs +1 -0
  353. package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
  354. package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
  355. package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
  356. package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
  357. package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
  358. package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
  359. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
  360. package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
  361. package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
  362. package/dist/esm/core/fetcher/Fetcher.mjs +270 -0
  363. package/dist/esm/core/fetcher/Headers.d.mts +2 -0
  364. package/dist/esm/core/fetcher/Headers.mjs +82 -0
  365. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
  366. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
  367. package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
  368. package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
  369. package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
  370. package/dist/esm/core/fetcher/Supplier.mjs +19 -0
  371. package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
  372. package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
  373. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
  374. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +55 -0
  375. package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
  376. package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
  377. package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
  378. package/dist/esm/core/fetcher/getHeader.mjs +8 -0
  379. package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
  380. package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
  381. package/dist/esm/core/fetcher/getResponseBody.d.mts +17 -0
  382. package/dist/esm/core/fetcher/getResponseBody.mjs +81 -0
  383. package/dist/esm/core/fetcher/index.d.mts +13 -0
  384. package/dist/esm/core/fetcher/index.mjs +7 -0
  385. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  386. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +170 -0
  387. package/dist/esm/core/fetcher/makeRequest.d.mts +11 -0
  388. package/dist/esm/core/fetcher/makeRequest.mjs +87 -0
  389. package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
  390. package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
  391. package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
  392. package/dist/esm/core/fetcher/requestWithRetries.mjs +88 -0
  393. package/dist/esm/core/fetcher/signals.d.mts +6 -0
  394. package/dist/esm/core/fetcher/signals.mjs +28 -0
  395. package/dist/esm/core/headers.d.mts +2 -0
  396. package/dist/esm/core/headers.mjs +27 -0
  397. package/dist/esm/core/index.d.mts +6 -0
  398. package/dist/esm/core/index.mjs +6 -0
  399. package/dist/esm/core/json.d.mts +15 -0
  400. package/dist/esm/core/json.mjs +19 -0
  401. package/dist/esm/core/logging/exports.d.mts +18 -0
  402. package/dist/esm/core/logging/exports.mjs +9 -0
  403. package/dist/esm/core/logging/index.d.mts +1 -0
  404. package/dist/esm/core/logging/index.mjs +1 -0
  405. package/dist/esm/core/logging/logger.d.mts +126 -0
  406. package/dist/esm/core/logging/logger.mjs +138 -0
  407. package/dist/esm/core/requestBody.d.mts +12 -0
  408. package/dist/esm/core/requestBody.mjs +23 -0
  409. package/dist/esm/core/runtime/index.d.mts +1 -0
  410. package/dist/esm/core/runtime/index.mjs +1 -0
  411. package/dist/esm/core/runtime/runtime.d.mts +28 -0
  412. package/dist/esm/core/runtime/runtime.mjs +172 -0
  413. package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
  414. package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
  415. package/dist/esm/core/url/encodePathParam.d.mts +3 -0
  416. package/dist/esm/core/url/encodePathParam.mjs +24 -0
  417. package/dist/esm/core/url/index.d.mts +4 -0
  418. package/dist/esm/core/url/index.mjs +4 -0
  419. package/dist/esm/core/url/join.d.mts +1 -0
  420. package/dist/esm/core/url/join.mjs +65 -0
  421. package/dist/esm/core/url/qs.d.mts +7 -0
  422. package/dist/esm/core/url/qs.mjs +73 -0
  423. package/dist/esm/environments.d.mts +4 -0
  424. package/dist/esm/environments.mjs +4 -0
  425. package/dist/esm/errors/SpyglassError.d.mts +15 -0
  426. package/dist/esm/errors/SpyglassError.mjs +49 -0
  427. package/dist/esm/errors/SpyglassTimeoutError.d.mts +6 -0
  428. package/dist/esm/errors/SpyglassTimeoutError.mjs +15 -0
  429. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  430. package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
  431. package/dist/esm/errors/index.d.mts +2 -0
  432. package/dist/esm/errors/index.mjs +2 -0
  433. package/dist/esm/exports.d.mts +1 -0
  434. package/dist/esm/exports.mjs +1 -0
  435. package/dist/esm/index.d.mts +6 -0
  436. package/dist/esm/index.mjs +5 -0
  437. package/dist/esm/version.d.mts +1 -0
  438. package/dist/esm/version.mjs +1 -0
  439. package/package.json +116 -5
  440. package/reference.md +852 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Spyglass
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,387 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/spyglass-so/spyglass-typescript/main/assets/wordmark.svg" alt="Spyglass" width="360">
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <h3>The API layer for the social internet</h3>
5
+ <p>Official TypeScript & Node.js SDK for the Spyglass API — search brands, creators, and the ads they run.</p>
6
+
7
+ <a href="https://app.spyglass.so">
8
+ <img src="https://img.shields.io/badge/Get_Started-111111?style=for-the-badge" alt="Get Started">
9
+ </a>
10
+ <a href="https://docs.spyglass.so">
11
+ <img src="https://img.shields.io/badge/Documentation-4A4A4A?style=for-the-badge" alt="Documentation">
12
+ </a>
13
+ <a href="https://spyglass.so">
14
+ <img src="https://img.shields.io/badge/spyglass.so-0A0A0A?style=for-the-badge" alt="spyglass.so">
15
+ </a>
16
+ </div>
17
+
18
+ <br>
19
+
20
+ <div align="center">
21
+ <a href="https://github.com/spyglass-so/spyglass-typescript/blob/main/LICENSE">
22
+ <img src="https://img.shields.io/github/license/spyglass-so/spyglass-typescript" alt="License">
23
+ </a>
24
+ <a href="https://github.com/spyglass-so/spyglass-typescript/stargazers">
25
+ <img src="https://img.shields.io/github/stars/spyglass-so/spyglass-typescript?style=social" alt="Stars">
26
+ </a>
27
+ <a href="https://www.npmjs.com/package/@spyglasshq/sdk">
28
+ <img src="https://img.shields.io/npm/v/@spyglasshq/sdk" alt="npm">
29
+ </a>
30
+ <a href="https://github.com/spyglass-so/spyglass-python">
31
+ <img src="https://img.shields.io/badge/Python_SDK-spyglass--sdk-3776AB?logo=python&logoColor=white" alt="Python SDK">
32
+ </a>
33
+ </div>
34
+
35
+ ---
36
+
37
+ **`@spyglasshq/sdk`** is the official TypeScript and Node.js client for the [Spyglass API](https://docs.spyglass.so). Resolve brands and creators, search across millions of Meta, Instagram, and TikTok creatives with natural-language briefs or structured filters, and extract hooks, personas, landing pages, and public comments.
38
+
39
+ > Looking for Python? See [`spyglass-so/spyglass-python`](https://github.com/spyglass-so/spyglass-python) (`pip install spyglass-sdk`).
40
+
41
+ ## Table of Contents
42
+
43
+ - [Installation](#installation)
44
+ - [Quickstart](#quickstart)
45
+ - [Core Workflows](#core-workflows)
46
+ - [Search Brands](#1-search-brands)
47
+ - [Search Ad Creatives & Social Media](#2-search-ad-creatives--social-media)
48
+ - [Discover Creators](#3-discover-creators)
49
+ - [Creative Insights & Landing Pages](#4-creative-insights--landing-pages)
50
+ - [Post Comments](#5-post-comments)
51
+ - [Index a New Brand](#6-index-a-new-brand)
52
+ - [Check Team Credit Usage](#7-check-team-credit-usage)
53
+ - [API Reference Overview](#api-reference-overview)
54
+ - [TypeScript Types](#typescript-types)
55
+ - [Error Handling](#error-handling)
56
+ - [Advanced Configuration](#advanced-configuration)
57
+ - [Retries, Timeouts & Abort Signals](#retries-timeouts--abort-signals)
58
+ - [Raw Response & Headers](#raw-response--headers)
59
+ - [Tree-Shakeable Subpackage Imports](#tree-shakeable-subpackage-imports)
60
+ - [Logging](#logging)
61
+ - [Runtime Compatibility](#runtime-compatibility)
62
+ - [Billing & Conventions](#billing--conventions)
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ npm install @spyglasshq/sdk
68
+ # or
69
+ pnpm add @spyglasshq/sdk
70
+ # or
71
+ yarn add @spyglasshq/sdk
72
+ # or
73
+ bun add @spyglasshq/sdk
74
+ ```
75
+
76
+ ## Quickstart
77
+
78
+ 1. Create an API key in **[Settings → API](https://app.spyglass.so)**. Keys start with `sg_live_` and are shown once.
79
+ 2. Initialize `Spyglass` and make your first call:
80
+
81
+ ```ts
82
+ import { Spyglass } from "@spyglasshq/sdk";
83
+
84
+ const client = new Spyglass({
85
+ token: process.env.SPYGLASS_API_KEY!,
86
+ });
87
+
88
+ // 1. Resolve a brand by name
89
+ const { brands } = await client.search.brands({
90
+ names: ["Nike"],
91
+ limit: 1,
92
+ });
93
+
94
+ const brand = brands[0];
95
+
96
+ if (brand) {
97
+ // 2. Search the creatives that brand is running
98
+ const { media } = await client.search.getMedia({
99
+ brandId: brand.id,
100
+ query: "marathon running shoes comfort",
101
+ limit: 10,
102
+ });
103
+
104
+ for (const ad of media) {
105
+ console.log({
106
+ id: ad.id,
107
+ hook: ad.hook,
108
+ coreAngle: ad.coreAngle,
109
+ targetPersona: ad.targetPersona,
110
+ daysRun: ad.daysRun,
111
+ url: ad.url,
112
+ });
113
+ }
114
+ }
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Core Workflows
120
+
121
+ ### 1. Search Brands
122
+
123
+ Search advertisers by name (`names`), social handle (`igUsername`, `tiktokUsername`), known IDs (`brandIds`), or a natural-language brief (`query`). You can also combine `names` + `query` to rank a specific set of brands against a brief.
124
+
125
+ ```ts
126
+ // Fuzzy name lookup
127
+ const byName = await client.search.brands({
128
+ names: ["Athletic Greens", "AG1"],
129
+ limit: 5,
130
+ });
131
+
132
+ // Natural-language discovery
133
+ const byBrief = await client.search.brands({
134
+ query: "DTC electrolyte and hydration powder brands",
135
+ limit: 10,
136
+ });
137
+ ```
138
+
139
+ ### 2. Search Ad Creatives & Social Media
140
+
141
+ Pass `brandId` to inspect a specific brand or creator's creatives, or omit `brandId` and pass `query` to search across the entire Spyglass index. Combine semantic search with structured filters:
142
+
143
+ ```ts
144
+ // Optional: look up valid product taxonomy paths first (free call)
145
+ const { taxonomies } = await client.search.taxonomies({
146
+ query: "running shoes",
147
+ });
148
+
149
+ const { media, count } = await client.search.getMedia({
150
+ query: "UGC founder story explaining product benefits",
151
+ channel: ["META_AD", "TIKTOK"],
152
+ format: ["VIDEO"],
153
+ status: "ACTIVE",
154
+ taxonomy: taxonomies.slice(0, 2),
155
+ minDaysRun: 14,
156
+ limit: 20,
157
+ offset: 0,
158
+ });
159
+ ```
160
+
161
+ Each item in `media` includes creative intelligence extracted by Spyglass:
162
+ - **Copy & Strategy:** `hook`, `summary`, `coreAngle`, `targetPersona`, `painPoints`, `sellingPoints`
163
+ - **Creative Metadata:** `type` (`VIDEO`, `IMAGE`, `CAROUSEL`, `DPA`, `DCO`), `durationInSeconds`, `url`, `urls`, `thumbnailUrl`, `ugcCharacter`
164
+ - **Distribution & Performance:** `platforms`, `startAt`, `endAt`, `daysRun`, `viewCount`, `likeCount`, `commentCount`, `impressionPercentile`
165
+
166
+ ### 3. Discover Creators
167
+
168
+ Search creators by handle, name, or natural-language brief, and filter by demographic and profile attributes (`gender`, `ageRange`, `ethnicity`, `location`, `language`):
169
+
170
+ ```ts
171
+ const { creators } = await client.search.creators({
172
+ query: "skincare routine and dermatology tips",
173
+ gender: "female",
174
+ ageRange: ["25-34"],
175
+ location: ["US"],
176
+ language: ["en"],
177
+ limit: 20,
178
+ });
179
+ ```
180
+
181
+ ### 4. Creative Insights & Landing Pages
182
+
183
+ Pull clustered creative themes (`HOOK`, `USP`, `PERSONA`, `MEDIA_MIX`) and ranked destination landing pages for any brand:
184
+
185
+ ```ts
186
+ // Ranked hooks + weekly volume breakdown over the last 90 days
187
+ const insights = await client.search.getBrandMediaInsights({
188
+ id: brand.id,
189
+ type: "HOOK",
190
+ maxDaysBack: 90,
191
+ limit: 10,
192
+ });
193
+
194
+ // Top landing pages where the brand sends ad traffic
195
+ const { landingPages } = await client.search.getBrandLandingPages({
196
+ id: brand.id,
197
+ showInactive: "false",
198
+ limit: 20,
199
+ });
200
+ ```
201
+
202
+ ### 5. Post Comments
203
+
204
+ Fetch public comments from Instagram posts/reels (by shortcode or URL) and TikTok videos (by video ID or URL):
205
+
206
+ ```ts
207
+ const { posts } = await client.search.getComments({
208
+ instagramIds: ["https://www.instagram.com/reel/C2xY9abcD1e/"],
209
+ tiktokIds: ["https://www.tiktok.com/@nike/video/7234567890123456789"],
210
+ limit: 1, // comment pages per post
211
+ });
212
+ ```
213
+
214
+ ### 6. Index a New Brand
215
+
216
+ If Spyglass doesn't have a brand yet, submit its website or social profile URL (`POST /account/index` is free) and poll until `status` is `"ready"`:
217
+
218
+ ```ts
219
+ const indexed = await client.indexing.indexBrand({
220
+ websiteUrl: "https://www.on.com",
221
+ });
222
+
223
+ // "already_exists" can be queried immediately; "indexing" queues a background sync
224
+ let status = indexed.status;
225
+ while (status === "indexing") {
226
+ await new Promise((resolve) => setTimeout(resolve, 3000));
227
+ const check = await client.indexing.indexBrandStatus({ id: indexed.brandId });
228
+ status = check.status;
229
+ }
230
+
231
+ if (status === "ready" || status === "already_exists") {
232
+ const account = await client.search.getAccount({ id: indexed.brandId });
233
+ console.log("Indexed account:", account.name);
234
+ }
235
+ ```
236
+
237
+ ### 7. Check Team Credit Usage
238
+
239
+ Check your team's remaining monthly credits and current billing window (free call):
240
+
241
+ ```ts
242
+ const usage = await client.account.getCreditUsage();
243
+ console.log(`Remaining: ${usage.remainingCredits} / ${usage.planCredits}`);
244
+ ```
245
+
246
+ ---
247
+
248
+ ## API Reference Overview
249
+
250
+ | SDK Method | HTTP Endpoint | Cost | Rate Limit |
251
+ | --- | --- | --- | --- |
252
+ | `client.search.brands(req)` | `POST /brands` | $0.0020 / brand returned | 120 / min |
253
+ | `client.search.creators(req)` | `POST /creators` | $0.0020 / creator returned | 120 / min |
254
+ | `client.search.getAccount({ id })` | `GET /account/{id}` | $0.0020 / account returned | 120 / min |
255
+ | `client.search.getMedia(req)` | `POST /media` | $0.0010 / creative returned | 120 / min |
256
+ | `client.search.taxonomies({ query })` | `GET /taxonomies` | Free | 120 / min |
257
+ | `client.search.getBrandMediaInsights(req)` | `GET /account/{id}/insights` | $0.0010 / cluster returned | 120 / min |
258
+ | `client.search.getBrandLandingPages(req)` | `GET /account/{id}/landing-pages` | $0.0050 / landing page returned | 120 / min |
259
+ | `client.search.getComments(req)` | `POST /comments` | $0.0100 / live page fetched | 20 / min |
260
+ | `client.indexing.indexBrand(req)` | `POST /account/index` | Free | 50 / min |
261
+ | `client.indexing.indexBrandStatus({ id })` | `GET /account/{id}/index-status` | Free | 300 / min |
262
+ | `client.account.getCreditUsage()` | `GET /team/credit-usage` | Free | 120 / min |
263
+
264
+ Full method signatures and parameter types are available in [`reference.md`](https://github.com/spyglass-so/spyglass-typescript/blob/main/reference.md) and at [docs.spyglass.so](https://docs.spyglass.so).
265
+
266
+ ---
267
+
268
+ ## TypeScript Types
269
+
270
+ All request and response types are exported under the `spyglass` namespace:
271
+
272
+ ```ts
273
+ import { spyglass } from "@spyglasshq/sdk";
274
+
275
+ const request: spyglass.GetMediaRequest = {
276
+ query: "summer sale",
277
+ channel: ["META_AD"],
278
+ limit: 25,
279
+ };
280
+
281
+ type MediaItem = spyglass.GetMediaResponse.Media.Item;
282
+ ```
283
+
284
+ ## Error Handling
285
+
286
+ When the API returns a non-2xx status code (`400`, `401`, `402` out of credits, `404`, `429` rate limit, or `5xx`), the SDK throws a `SpyglassError` (or a status-specific subclass such as `PaymentRequiredError` or `TooManyRequestsError`):
287
+
288
+ ```ts
289
+ import { SpyglassError } from "@spyglasshq/sdk";
290
+
291
+ try {
292
+ await client.search.brands({ names: ["Nike"], limit: 5 });
293
+ } catch (err) {
294
+ if (err instanceof SpyglassError) {
295
+ console.error("Status:", err.statusCode);
296
+ console.error("Message:", err.message);
297
+ console.error("Body:", err.body);
298
+ }
299
+ }
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Advanced Configuration
305
+
306
+ ### Retries, Timeouts & Abort Signals
307
+
308
+ The SDK defaults to a **60-second timeout** and **2 automatic retries** with exponential backoff on `408`, `429`, and `5xx` responses. You can configure these on the client or override them per request:
309
+
310
+ ```ts
311
+ const controller = new AbortController();
312
+
313
+ const response = await client.search.getMedia(
314
+ { query: "protein bar", limit: 10 },
315
+ {
316
+ timeoutInSeconds: 30,
317
+ maxRetries: 3,
318
+ abortSignal: controller.signal,
319
+ headers: { "X-Custom-Header": "value" },
320
+ },
321
+ );
322
+ ```
323
+
324
+ ### Raw Response & Headers
325
+
326
+ Chain `.withRawResponse()` on any request promise to inspect HTTP status codes and headers alongside parsed data:
327
+
328
+ ```ts
329
+ const { data, rawResponse } = await client.search
330
+ .brands({ names: ["Nike"], limit: 1 })
331
+ .withRawResponse();
332
+
333
+ console.log(data.brands);
334
+ console.log(rawResponse.headers.get("retry-after"));
335
+ ```
336
+
337
+ ### Tree-Shakeable Subpackage Imports
338
+
339
+ Import individual resource clients directly for minimal bundle sizes:
340
+
341
+ ```ts
342
+ import { SearchClient } from "@spyglasshq/sdk/search";
343
+ import { IndexingClient } from "@spyglasshq/sdk/indexing";
344
+ import { AccountClient } from "@spyglasshq/sdk/account";
345
+ ```
346
+
347
+ ### Logging
348
+
349
+ Enable debug or info logging on the client:
350
+
351
+ ```ts
352
+ import { Spyglass, logging } from "@spyglasshq/sdk";
353
+
354
+ const client = new Spyglass({
355
+ token: process.env.SPYGLASS_API_KEY!,
356
+ logging: {
357
+ level: logging.LogLevel.Debug,
358
+ logger: new logging.ConsoleLogger(),
359
+ silent: false,
360
+ },
361
+ });
362
+ ```
363
+
364
+ ### Runtime Compatibility
365
+
366
+ Zero external runtime dependencies. Works out of the box in:
367
+ - **Node.js** 18+
368
+ - **Bun** 1.0+
369
+ - **Deno** v1.25+
370
+ - **Vercel Functions** & **Cloudflare Workers**
371
+
372
+ ## Billing & Conventions
373
+
374
+ - **Credits per row:** Most endpoints charge against your monthly plan credits per item returned (`count` in the response). Always bound requests with `limit`. Semantic `query` searches on `/media`, `/brands`, and `/creators` run a language model and bill a minimum of 1 row even when 0 rows match. See [Billing docs](https://docs.spyglass.so/documentation/get-started/billing).
375
+ - **Pagination:** Page through results with `offset` and `limit`. `count` is the number of rows in *this* response (not the total across all pages). Stop paging when `count < limit`.
376
+ - **Server-side only:** The Spyglass API is designed for backend services, data pipelines, and AI agents. Do not expose your `sg_live_` key in browser client code.
377
+
378
+ ## Support
379
+
380
+ - **Documentation:** [docs.spyglass.so](https://docs.spyglass.so)
381
+ - **API Playground:** [app.spyglass.so/playground](https://app.spyglass.so/playground)
382
+ - **Issues:** [github.com/spyglass-so/spyglass-typescript/issues](https://github.com/spyglass-so/spyglass-typescript/issues)
383
+ - **Email:** [support@spyglass.so](mailto:support@spyglass.so)
384
+
385
+ ## License
386
+
387
+ [MIT](https://github.com/spyglass-so/spyglass-typescript/blob/main/LICENSE)
@@ -0,0 +1,54 @@
1
+ import { BearerAuthProvider } from "./auth/BearerAuthProvider.js";
2
+ import * as core from "./core/index.js";
3
+ import type * as environments from "./environments.js";
4
+ export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | BearerAuthProvider.AuthOptions;
5
+ export type BaseClientOptions = {
6
+ environment?: core.Supplier<environments.SpyglassEnvironment | string>;
7
+ /** Specify a custom URL to connect the client to. */
8
+ baseUrl?: core.Supplier<string>;
9
+ /** Additional headers to include in requests. */
10
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
11
+ /** The default maximum time to wait for a response in seconds. */
12
+ timeoutInSeconds?: number;
13
+ /** The default number of times to retry the request. Defaults to 2. */
14
+ maxRetries?: number;
15
+ /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */
16
+ fetch?: typeof fetch;
17
+ /** Configure logging for the client. */
18
+ logging?: core.logging.LogConfig | core.logging.Logger;
19
+ /** Default options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */
20
+ stream?: {
21
+ reconnectionEnabled?: boolean;
22
+ maxReconnectionAttempts?: number;
23
+ };
24
+ /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
25
+ auth?: AuthOption;
26
+ } & BearerAuthProvider.AuthOptions;
27
+ export interface BaseRequestOptions {
28
+ /** The maximum time to wait for a response in seconds. */
29
+ timeoutInSeconds?: number;
30
+ /** The number of times to retry the request. Defaults to 2. */
31
+ maxRetries?: number;
32
+ /** A hook to abort the request. */
33
+ abortSignal?: AbortSignal;
34
+ /** Additional query string parameters to include in the request. */
35
+ queryParams?: Record<string, unknown>;
36
+ /** A dictionary containing additional parameters to spread into the request's body. */
37
+ additionalBodyParameters?: Record<string, unknown>;
38
+ /** Additional headers to include in the request. */
39
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
40
+ /** Options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */
41
+ stream?: {
42
+ reconnectionEnabled?: boolean;
43
+ maxReconnectionAttempts?: number;
44
+ };
45
+ }
46
+ export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
47
+ logging: core.logging.Logger;
48
+ authProvider?: core.AuthProvider;
49
+ };
50
+ export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
51
+ authProvider: core.AuthProvider;
52
+ };
53
+ export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
54
+ export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.normalizeClientOptions = normalizeClientOptions;
38
+ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
+ const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
40
+ const headers_js_1 = require("./core/headers.js");
41
+ const core = __importStar(require("./core/index.js"));
42
+ function normalizeClientOptions(options) {
43
+ const headers = (0, headers_js_1.mergeHeaders)({
44
+ "X-Fern-Language": "JavaScript",
45
+ "X-Fern-SDK-Name": "@spyglasshq/sdk",
46
+ "X-Fern-SDK-Version": "0.1.1",
47
+ "User-Agent": "@spyglasshq/sdk/0.1.1",
48
+ "X-Fern-Runtime": core.RUNTIME.type,
49
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
50
+ }, options === null || options === void 0 ? void 0 : options.headers);
51
+ return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
52
+ }
53
+ function normalizeClientOptionsWithAuth(options) {
54
+ var _a;
55
+ const normalized = normalizeClientOptions(options);
56
+ if (options.auth === false) {
57
+ normalized.authProvider = new core.NoOpAuthProvider();
58
+ return normalized;
59
+ }
60
+ if (options.auth != null) {
61
+ if (typeof options.auth === "function") {
62
+ normalized.authProvider = { getAuthRequest: options.auth };
63
+ return normalized;
64
+ }
65
+ if (core.isAuthProvider(options.auth)) {
66
+ normalized.authProvider = options.auth;
67
+ return normalized;
68
+ }
69
+ Object.assign(normalized, options.auth);
70
+ }
71
+ const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
72
+ (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider_js_1.BearerAuthProvider(normalizedWithNoOpAuthProvider));
73
+ return normalized;
74
+ }
75
+ function withNoOpAuthProvider(options) {
76
+ return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
77
+ }
@@ -0,0 +1,32 @@
1
+ import { AccountClient } from "./api/resources/account/client/Client.js";
2
+ import { IndexingClient } from "./api/resources/indexing/client/Client.js";
3
+ import { SearchClient } from "./api/resources/search/client/Client.js";
4
+ import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
5
+ import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
6
+ import * as core from "./core/index.js";
7
+ export declare namespace Spyglass {
8
+ type Options = BaseClientOptions;
9
+ interface RequestOptions extends BaseRequestOptions {
10
+ }
11
+ }
12
+ export declare class Spyglass {
13
+ protected readonly _options: NormalizedClientOptionsWithAuth<Spyglass.Options>;
14
+ protected _search: SearchClient | undefined;
15
+ protected _account: AccountClient | undefined;
16
+ protected _indexing: IndexingClient | undefined;
17
+ constructor(options: Spyglass.Options);
18
+ get search(): SearchClient;
19
+ get account(): AccountClient;
20
+ get indexing(): IndexingClient;
21
+ /**
22
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
23
+ * This is useful for making requests to endpoints not yet supported in the SDK.
24
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
25
+ *
26
+ * @param {Request | string | URL} input - The URL, path, or Request object.
27
+ * @param {RequestInit} init - Standard fetch RequestInit options.
28
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
29
+ * @returns {Promise<Response>} A standard Response object.
30
+ */
31
+ fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
32
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.Spyglass = void 0;
47
+ const Client_js_1 = require("./api/resources/account/client/Client.js");
48
+ const Client_js_2 = require("./api/resources/indexing/client/Client.js");
49
+ const Client_js_3 = require("./api/resources/search/client/Client.js");
50
+ const BaseClient_js_1 = require("./BaseClient.js");
51
+ const core = __importStar(require("./core/index.js"));
52
+ class Spyglass {
53
+ constructor(options) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
+ }
56
+ get search() {
57
+ var _a;
58
+ return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new Client_js_3.SearchClient(this._options)));
59
+ }
60
+ get account() {
61
+ var _a;
62
+ return ((_a = this._account) !== null && _a !== void 0 ? _a : (this._account = new Client_js_1.AccountClient(this._options)));
63
+ }
64
+ get indexing() {
65
+ var _a;
66
+ return ((_a = this._indexing) !== null && _a !== void 0 ? _a : (this._indexing = new Client_js_2.IndexingClient(this._options)));
67
+ }
68
+ /**
69
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
70
+ * This is useful for making requests to endpoints not yet supported in the SDK.
71
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
72
+ *
73
+ * @param {Request | string | URL} input - The URL, path, or Request object.
74
+ * @param {RequestInit} init - Standard fetch RequestInit options.
75
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
76
+ * @returns {Promise<Response>} A standard Response object.
77
+ */
78
+ fetch(input, init, requestOptions) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ var _a;
81
+ return core.makePassthroughRequest(input, init, {
82
+ baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : this._options.environment,
83
+ headers: this._options.headers,
84
+ timeoutInSeconds: this._options.timeoutInSeconds,
85
+ maxRetries: this._options.maxRetries,
86
+ fetch: this._options.fetch,
87
+ logging: this._options.logging,
88
+ getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
89
+ }, requestOptions);
90
+ });
91
+ }
92
+ }
93
+ exports.Spyglass = Spyglass;
@@ -0,0 +1,7 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as spyglass from "../index.js";
4
+ export declare class BadRequestError extends errors.SpyglassError {
5
+ readonly body: spyglass.Error_;
6
+ constructor(body: spyglass.Error_, rawResponse?: core.RawResponse);
7
+ }