uapi-sdk-python 0.1.17__py3-none-any.whl → 0.1.18__py3-none-any.whl

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.
uapi/client.py CHANGED
@@ -135,6 +135,9 @@ class UapiClient:
135
135
  _daily = _DailyApi(self._http)
136
136
  self.daily = _daily
137
137
  setattr(self, "Daily", _daily)
138
+ _dictionary = _DictionaryApi(self._http)
139
+ self.dictionary = _dictionary
140
+ setattr(self, "Dictionary", _dictionary)
138
141
  _game = _GameApi(self._http)
139
142
  self.game = _game
140
143
  setattr(self, "Game", _game)
@@ -174,6 +177,9 @@ class UapiClient:
174
177
  _zhi_neng_sou_suo = _ZhiNengSouSuoApi(self._http)
175
178
  self.zhi_neng_sou_suo = _zhi_neng_sou_suo
176
179
  setattr(self, "智能搜索", _zhi_neng_sou_suo)
180
+ _shui_yin_yu_aigc_biao_shi = _ShuiYinYuAigcBiaoShiApi(self._http)
181
+ self.shui_yin_yu_aigc_biao_shi = _shui_yin_yu_aigc_biao_shi
182
+ setattr(self, "水印与 AIGC 标识", _shui_yin_yu_aigc_biao_shi)
177
183
 
178
184
  @property
179
185
  def last_response_meta(self) -> Optional[ResponseMeta]:
@@ -404,6 +410,147 @@ class _DailyApi:
404
410
  disable_cache=_coerce_optional_bool(disable_cache),
405
411
  )
406
412
 
413
+ def get_daily_word(self, **kwargs):
414
+ r"""每日单词
415
+ 想给你的学习打卡、英语小组件或机器人推送加一个『每日单词』?这个接口每天给你一个稳定的单词,同一天多次请求结果一致。
416
+
417
+ ## 功能概述
418
+ 默认返回 1 个英文单词,支持按词库范围筛选,可选择是否附带例句和音标。也可以用 `count` 一次返回多个词,用于词汇复习列表。
419
+
420
+ ## 词库选项
421
+ - `all`:全部英文词库,适合通用每日推荐。
422
+ - `cet4`:大学英语四级词汇,适合基础复习。
423
+ - `cet6`:大学英语六级词汇,适合进阶复习。
424
+ - `ielts`:雅思词汇,适合留学考试准备。
425
+ - `toefl`:托福词汇,适合北美考试准备。
426
+ - `gre`:GRE 词汇,适合高阶词汇训练。
427
+
428
+ ## 使用须知
429
+ > [!IMPORTANT]
430
+ > `date` 与 `seed` 用于复现某一天或某个固定的取词结果,二者不能同时传入。
431
+ """
432
+ params = {}
433
+ body = {}
434
+
435
+ if "query" == "query" and "lang" in kwargs:
436
+ params["lang"] = kwargs["lang"]
437
+
438
+ if "query" == "query" and "category" in kwargs:
439
+ params["category"] = kwargs["category"]
440
+
441
+ if "query" == "query" and "count" in kwargs:
442
+ params["count"] = kwargs["count"]
443
+
444
+ if "query" == "query" and "date" in kwargs:
445
+ params["date"] = kwargs["date"]
446
+
447
+ if "query" == "query" and "seed" in kwargs:
448
+ params["seed"] = kwargs["seed"]
449
+
450
+ if "query" == "query" and "example" in kwargs:
451
+ params["example"] = kwargs["example"]
452
+
453
+ if "query" == "query" and "phonetic" in kwargs:
454
+ params["phonetic"] = kwargs["phonetic"]
455
+
456
+ if "query" == "query" and "define" in kwargs:
457
+ params["define"] = kwargs["define"]
458
+
459
+ if "_t" in kwargs:
460
+ params["_t"] = kwargs["_t"]
461
+ disable_cache = kwargs.get("disable_cache")
462
+ if disable_cache is None and "disableCache" in kwargs:
463
+ disable_cache = kwargs["disableCache"]
464
+ path = "/api/v1/daily/word"
465
+
466
+ return self._http.request(
467
+ "GET",
468
+ path,
469
+ params=params,
470
+ json=body if body else None,
471
+ disable_cache=_coerce_optional_bool(disable_cache),
472
+ )
473
+
474
+
475
+ class _DictionaryApi:
476
+ def __init__(self, http: _HTTP):
477
+ self._http = http
478
+
479
+
480
+ def get_dictionary_audio(self, **kwargs):
481
+ r"""单词发音
482
+ 光看音标不知道怎么读?用这个接口为单词配上纯正的真人发音,并且支持英式与美式两种口音自由切换。
483
+
484
+ ## 功能概述
485
+ 只需传入单词文本和所需的口音类型,接口就会直接响应 `.mp3` 格式的二进制音频流。你可以直接把接口地址塞进前端的 `<audio>` 标签里播放,或者将其下载保存为本地音频文件。另外,“单词查询”接口中返回的 `audio` 字段,实际上也就是直接拼装好的本接口地址。
486
+
487
+ ## 使用须知
488
+ > [!NOTE]
489
+ > 本接口成功调用时返回的是 `audio/mpeg` 格式的二进制音频流,而不是常规的 JSON。如果在代码里使用 Fetch 或 Axios 调用并处理返回数据,请务必以 `blob` 或 `arraybuffer` 的形式接收响应内容。
490
+ """
491
+ params = {}
492
+ body = {}
493
+
494
+ if "query" == "query" and "word" in kwargs:
495
+ params["word"] = kwargs["word"]
496
+
497
+ if "query" == "query" and "accent" in kwargs:
498
+ params["accent"] = kwargs["accent"]
499
+
500
+ if "_t" in kwargs:
501
+ params["_t"] = kwargs["_t"]
502
+ disable_cache = kwargs.get("disable_cache")
503
+ if disable_cache is None and "disableCache" in kwargs:
504
+ disable_cache = kwargs["disableCache"]
505
+ path = "/api/v1/dictionary/audio"
506
+
507
+ return self._http.request(
508
+ "GET",
509
+ path,
510
+ params=params,
511
+ json=body if body else None,
512
+ disable_cache=_coerce_optional_bool(disable_cache),
513
+ )
514
+
515
+ def get_dictionary_lookup(self, **kwargs):
516
+ r"""单词查询
517
+ 想在自己的背单词应用、阅读插件或聊天机器人里加个查词功能?输入一个英文单词,就能立刻拿到一本详尽的“微型词典”。
518
+
519
+ ## 功能概述
520
+ 传入你要查询的英文单词,接口会返回一整份全方位的词条数据。数据结构是高度动态的——如果某个单词没有常见词组或近义词,对应的字段会自动省略,方便前端精简渲染。
521
+
522
+ ## 返回内容涵盖
523
+ - **音标与发音** (`phonetics`):包含英式(UK)与美式(US)音标,以及可直接在前端播放的发音音频链接。
524
+ - **中文释义** (`definitions`):按词性归类的中文翻译。
525
+ - **英英释义** (`english_definitions`):英文原汁原味的解释及附带的短例句。
526
+ - **词形变化** (`word_forms`):复数、过去式、比较级等形态转换。
527
+ - **词组与近义词** (`phrases` / `synonyms`):常见的搭配词组,以及按词性归类的近义词。
528
+ - **双语例句** (`examples`):真实语境下的中英双语例句。
529
+ """
530
+ params = {}
531
+ body = {}
532
+
533
+ if "query" == "query" and "word" in kwargs:
534
+ params["word"] = kwargs["word"]
535
+
536
+ if "query" == "query" and "lang" in kwargs:
537
+ params["lang"] = kwargs["lang"]
538
+
539
+ if "_t" in kwargs:
540
+ params["_t"] = kwargs["_t"]
541
+ disable_cache = kwargs.get("disable_cache")
542
+ if disable_cache is None and "disableCache" in kwargs:
543
+ disable_cache = kwargs["disableCache"]
544
+ path = "/api/v1/dictionary/lookup"
545
+
546
+ return self._http.request(
547
+ "GET",
548
+ path,
549
+ params=params,
550
+ json=body if body else None,
551
+ disable_cache=_coerce_optional_bool(disable_cache),
552
+ )
553
+
407
554
 
408
555
  class _GameApi:
409
556
  def __init__(self, http: _HTTP):
@@ -487,6 +634,50 @@ class _GameApi:
487
634
  disable_cache=_coerce_optional_bool(disable_cache),
488
635
  )
489
636
 
637
+ def get_game_minecraft_mods(self, **kwargs):
638
+ r"""搜索 MC Mod/插件
639
+ 想给你的启动器、服务器面板或资源推荐页加上 Mod/插件搜索?这个接口一次帮你检索 Modrinth 与 SpigotMC 上的资源。
640
+
641
+ ## 功能概述
642
+ 传入关键词,即可拿到资源名称、简介、作者、下载量、评分、项目页和下载地址。可以用 `source` 指定只搜某个平台,用 `type` 过滤资源类型,用 `limit` 控制每个平台返回的数量。
643
+
644
+ ## 使用须知
645
+ > [!NOTE]
646
+ > 默认会补全作者名与下载直链。如果只想要更快的基础搜索结果,设置 `enrich=false` 即可降低延迟。
647
+ """
648
+ params = {}
649
+ body = {}
650
+
651
+ if "query" == "query" and "query" in kwargs:
652
+ params["query"] = kwargs["query"]
653
+
654
+ if "query" == "query" and "source" in kwargs:
655
+ params["source"] = kwargs["source"]
656
+
657
+ if "query" == "query" and "type" in kwargs:
658
+ params["type"] = kwargs["type"]
659
+
660
+ if "query" == "query" and "limit" in kwargs:
661
+ params["limit"] = kwargs["limit"]
662
+
663
+ if "query" == "query" and "enrich" in kwargs:
664
+ params["enrich"] = kwargs["enrich"]
665
+
666
+ if "_t" in kwargs:
667
+ params["_t"] = kwargs["_t"]
668
+ disable_cache = kwargs.get("disable_cache")
669
+ if disable_cache is None and "disableCache" in kwargs:
670
+ disable_cache = kwargs["disableCache"]
671
+ path = "/api/v1/game/minecraft/mods"
672
+
673
+ return self._http.request(
674
+ "GET",
675
+ path,
676
+ params=params,
677
+ json=body if body else None,
678
+ disable_cache=_coerce_optional_bool(disable_cache),
679
+ )
680
+
490
681
  def get_game_minecraft_serverstatus(self, **kwargs):
491
682
  r"""查询 MC 服务器
492
683
  想在加入服务器前看看有多少人在线?或者检查一下服务器开没开?用这个接口就对了!
@@ -545,6 +736,79 @@ class _GameApi:
545
736
  disable_cache=_coerce_optional_bool(disable_cache),
546
737
  )
547
738
 
739
+ def get_game_minecraft_version(self, **kwargs):
740
+ r"""Minecraft 最新版本
741
+ 需要在启动器、服务器面板或机器人里实时显示 Minecraft 的最新版本?这个接口帮你一键拿到当前的正式版和快照版。
742
+
743
+ ## 功能概述
744
+ 无需任何参数,直接返回最新正式版(latest release)、最新快照版(latest snapshot)以及完整的版本列表。适合做版本提示、更新检测或服务端版本看板。
745
+
746
+ ## 使用须知
747
+ > [!NOTE]
748
+ > 数据会随新版本发布而更新,建议在客户端适当缓存,无需高频轮询。
749
+ """
750
+ params = {}
751
+ body = {}
752
+
753
+ if "_t" in kwargs:
754
+ params["_t"] = kwargs["_t"]
755
+ disable_cache = kwargs.get("disable_cache")
756
+ if disable_cache is None and "disableCache" in kwargs:
757
+ disable_cache = kwargs["disableCache"]
758
+ path = "/api/v1/game/minecraft/version"
759
+
760
+ return self._http.request(
761
+ "GET",
762
+ path,
763
+ params=params,
764
+ json=body if body else None,
765
+ disable_cache=_coerce_optional_bool(disable_cache),
766
+ )
767
+
768
+ def get_game_steam_servers(self, **kwargs):
769
+ r"""查询 Steam 游戏服务器
770
+ 想在自己的面板或社区里展示某款游戏的在线服务器?这个接口支持查询使用 A2S/Steam 服务器列表的多人游戏,例如 SCUM、ARK、Rust、CS2 等。
771
+
772
+ ## 功能概述
773
+ 传入游戏的 Steam AppID,即可获取当前在线的服务器列表,包含名称、IP、端口、当前/最大人数、地图等信息。你还可以用 `name` 做服务器名称模糊搜索,用 `limit` 控制返回数量。
774
+
775
+ ## 常见 AppID
776
+ - SCUM:`513710`
777
+ - ARK:`346110`
778
+ - Rust:`252490`
779
+ - Counter-Strike 2:`730`
780
+
781
+ ## 使用须知
782
+ > [!NOTE]
783
+ > 不确定游戏的 AppID?可以在 Steam 商店页地址中找到,或参考上面的常见 AppID 列表。
784
+ """
785
+ params = {}
786
+ body = {}
787
+
788
+ if "query" == "query" and "appid" in kwargs:
789
+ params["appid"] = kwargs["appid"]
790
+
791
+ if "query" == "query" and "name" in kwargs:
792
+ params["name"] = kwargs["name"]
793
+
794
+ if "query" == "query" and "limit" in kwargs:
795
+ params["limit"] = kwargs["limit"]
796
+
797
+ if "_t" in kwargs:
798
+ params["_t"] = kwargs["_t"]
799
+ disable_cache = kwargs.get("disable_cache")
800
+ if disable_cache is None and "disableCache" in kwargs:
801
+ disable_cache = kwargs["disableCache"]
802
+ path = "/api/v1/game/steam/servers"
803
+
804
+ return self._http.request(
805
+ "GET",
806
+ path,
807
+ params=params,
808
+ json=body if body else None,
809
+ disable_cache=_coerce_optional_bool(disable_cache),
810
+ )
811
+
548
812
  def get_game_steam_summary(self, **kwargs):
549
813
  r"""查询 Steam 用户
550
814
  想在你的网站或应用中展示用户的 Steam 个人资料?这个接口就是为你准备的。
@@ -664,6 +928,9 @@ class _ImageApi:
664
928
  if "query" == "query" and "date" in kwargs:
665
929
  params["date"] = kwargs["date"]
666
930
 
931
+ if "query" == "query" and "random" in kwargs:
932
+ params["random"] = kwargs["random"]
933
+
667
934
  if "query" == "query" and "resolution" in kwargs:
668
935
  params["resolution"] = kwargs["resolution"]
669
936
 
@@ -1412,10 +1679,10 @@ class _MiscApi:
1412
1679
  只传 `type` 参数,返回该平台当前的实时热榜。
1413
1680
 
1414
1681
  ### 时光机模式
1415
- 传 `type` + `time` 参数,返回最接近指定时间的热榜快照。如果不可用或无数据,会返回空。
1682
+ 传 `type` + `time` 参数,返回指定时间附近最近可展示的历史热榜快照。
1416
1683
 
1417
1684
  ### 搜索模式
1418
- 传 `type` + `keyword` + `time_start` + `time_end` 参数,在指定时间范围内搜索包含关键词的热榜条目。可选传 `limit` 限制返回数量。
1685
+ 传 `type` + `keyword` + `time_start` + `time_end` 参数,在指定历史时间范围内搜索包含关键词的热榜条目。可选传 `limit` 限制返回数量。
1419
1686
  """
1420
1687
  params = {}
1421
1688
  body = {}
@@ -1489,6 +1756,71 @@ class _MiscApi:
1489
1756
  disable_cache=_coerce_optional_bool(disable_cache),
1490
1757
  )
1491
1758
 
1759
+ def get_misc_movie_box_office(self, **kwargs):
1760
+ r"""查询电影票房
1761
+ 正在做影视类应用,想直观展示今天哪部电影最卖座?大盘总票房突破了多少?这个接口能帮你实时获取院线大盘和影片票房排名。
1762
+
1763
+ ## 功能概述
1764
+ 调用此接口,无需任何参数,即可获取当前实时的电影市场大盘数据(包含总票房、总场次、总人次),以及每一部上映影片的具体表现(包括票房明细、排片占比、上座率、场均人次和累计票房等)。
1765
+ """
1766
+ params = {}
1767
+ body = {}
1768
+
1769
+ if "_t" in kwargs:
1770
+ params["_t"] = kwargs["_t"]
1771
+ disable_cache = kwargs.get("disable_cache")
1772
+ if disable_cache is None and "disableCache" in kwargs:
1773
+ disable_cache = kwargs["disableCache"]
1774
+ path = "/api/v1/misc/movie-box-office"
1775
+
1776
+ return self._http.request(
1777
+ "GET",
1778
+ path,
1779
+ params=params,
1780
+ json=body if body else None,
1781
+ disable_cache=_coerce_optional_bool(disable_cache),
1782
+ )
1783
+
1784
+ def get_misc_movie_rating_rank(self, **kwargs):
1785
+ r"""电影收视排行查询
1786
+ 想做影视榜单页或选题分析?这个接口提供影视的收视、热度和评分排行,既能查实时榜,也能按日、周、月回看历史快照。
1787
+
1788
+ ## 功能概述
1789
+ 用 `channel` 切换全网、卫视、网络平台或院线榜单,用 `period` + `date` 查询历史日榜、周榜和月榜。适合影视资讯页、数据看板、自媒体选题和内容运营分析。
1790
+ """
1791
+ params = {}
1792
+ body = {}
1793
+
1794
+ if "query" == "query" and "channel" in kwargs:
1795
+ params["channel"] = kwargs["channel"]
1796
+
1797
+ if "query" == "query" and "platform" in kwargs:
1798
+ params["platform"] = kwargs["platform"]
1799
+
1800
+ if "query" == "query" and "limit" in kwargs:
1801
+ params["limit"] = kwargs["limit"]
1802
+
1803
+ if "query" == "query" and "period" in kwargs:
1804
+ params["period"] = kwargs["period"]
1805
+
1806
+ if "query" == "query" and "date" in kwargs:
1807
+ params["date"] = kwargs["date"]
1808
+
1809
+ if "_t" in kwargs:
1810
+ params["_t"] = kwargs["_t"]
1811
+ disable_cache = kwargs.get("disable_cache")
1812
+ if disable_cache is None and "disableCache" in kwargs:
1813
+ disable_cache = kwargs["disableCache"]
1814
+ path = "/api/v1/misc/movie-rating-rank"
1815
+
1816
+ return self._http.request(
1817
+ "GET",
1818
+ path,
1819
+ params=params,
1820
+ json=body if body else None,
1821
+ disable_cache=_coerce_optional_bool(disable_cache),
1822
+ )
1823
+
1492
1824
  def get_misc_phoneinfo(self, **kwargs):
1493
1825
  r"""查询手机归属地
1494
1826
  想知道一个手机号码来自哪里?是移动、联通还是电信?这个接口可以告诉你答案。
@@ -1524,21 +1856,6 @@ class _MiscApi:
1524
1856
  ## 功能概述
1525
1857
  这是一个强大的随机数生成器。你可以指定生成的范围(最大/最小值)、数量、是否允许重复、以及是否生成小数(并指定小数位数)。
1526
1858
 
1527
- ## 流程图
1528
- ```mermaid
1529
- graph TD
1530
- A[开始] --> B{参数校验};
1531
- B --> |通过| C{是否允许小数?};
1532
- C --> |是| D[生成随机小数];
1533
- C --> |否| E[生成随机整数];
1534
- D --> F{是否允许重复?};
1535
- E --> F;
1536
- F --> |是| G[直接生成指定数量];
1537
- F --> |否| H[生成不重复的数字];
1538
- G --> I[返回结果];
1539
- H --> I;
1540
- B --> |失败| J[返回 400 错误];
1541
- ```
1542
1859
  ## 使用须知
1543
1860
  > [!WARNING]
1544
1861
  > **不重复生成的逻辑限制**
@@ -1701,9 +2018,6 @@ graph TD
1701
2018
  if "query" == "query" and "phone" in kwargs:
1702
2019
  params["phone"] = kwargs["phone"]
1703
2020
 
1704
- if "query" == "query" and "full" in kwargs:
1705
- params["full"] = kwargs["full"]
1706
-
1707
2021
  if "_t" in kwargs:
1708
2022
  params["_t"] = kwargs["_t"]
1709
2023
  disable_cache = kwargs.get("disable_cache")
@@ -1787,6 +2101,53 @@ graph TD
1787
2101
  disable_cache=_coerce_optional_bool(disable_cache),
1788
2102
  )
1789
2103
 
2104
+ def get_misc_weather_history(self, **kwargs):
2105
+ r"""查询历史天气
2106
+ 想知道某个城市过去一段时间有没有下雨、降雨量是多少?这个接口用于查询过去最多 366 天的城市每日历史天气。
2107
+
2108
+ ## 功能概述
2109
+ 支持按 `city`、`adcode` 或客户端 IP 自动定位查询。你可以传 `start_date` + `end_date` 指定日期范围,也可以只传 `days` 回看最近若干天。返回结果重点包含 `rained` 与 `rain`,适合做出行复盘、农业记录、气象看板和数据分析。
2110
+
2111
+ ## 使用须知
2112
+ > [!NOTE]
2113
+ > 定位优先级:`adcode` > `city` > IP 自动定位。同时传 `start_date` 和 `days` 时,以 `start_date` + `end_date` 区间为准。
2114
+ """
2115
+ params = {}
2116
+ body = {}
2117
+
2118
+ if "query" == "query" and "city" in kwargs:
2119
+ params["city"] = kwargs["city"]
2120
+
2121
+ if "query" == "query" and "adcode" in kwargs:
2122
+ params["adcode"] = kwargs["adcode"]
2123
+
2124
+ if "query" == "query" and "start_date" in kwargs:
2125
+ params["start_date"] = kwargs["start_date"]
2126
+
2127
+ if "query" == "query" and "end_date" in kwargs:
2128
+ params["end_date"] = kwargs["end_date"]
2129
+
2130
+ if "query" == "query" and "days" in kwargs:
2131
+ params["days"] = kwargs["days"]
2132
+
2133
+ if "query" == "query" and "lang" in kwargs:
2134
+ params["lang"] = kwargs["lang"]
2135
+
2136
+ if "_t" in kwargs:
2137
+ params["_t"] = kwargs["_t"]
2138
+ disable_cache = kwargs.get("disable_cache")
2139
+ if disable_cache is None and "disableCache" in kwargs:
2140
+ disable_cache = kwargs["disableCache"]
2141
+ path = "/api/v1/misc/weather/history"
2142
+
2143
+ return self._http.request(
2144
+ "GET",
2145
+ path,
2146
+ params=params,
2147
+ json=body if body else None,
2148
+ disable_cache=_coerce_optional_bool(disable_cache),
2149
+ )
2150
+
1790
2151
  def get_misc_worldtime(self, **kwargs):
1791
2152
  r"""查询世界时间
1792
2153
  需要和国外的朋友开会,想知道他那边现在几点?用这个接口一查便知。
@@ -2200,6 +2561,64 @@ class _PoemApi:
2200
2561
  disable_cache=_coerce_optional_bool(disable_cache),
2201
2562
  )
2202
2563
 
2564
+ def get_saying_random(self, **kwargs):
2565
+ r"""一言(随机/每日/场景/此刻)
2566
+ 一言接口,返回一条随机语录。通过 `mode` 参数切换四种返回方式,并支持按来源、分类、标签过滤。
2567
+
2568
+ ## 四种模式(`mode`)
2569
+ - **`random`(默认)**:每次调用随机返回一条语录。
2570
+ - **`daily`**:同一天内返回固定的同一条,适合每日打卡、签到等场景。
2571
+ - **`recommend`**:配合 `scene` 参数,返回指定场景(如 `night`、`morning`)的语录。
2572
+ - **`moment`**:根据请求时所处时段,自动返回应景语录。
2573
+
2574
+ ## 语言控制
2575
+ 语料分中英文两类,可通过 `source` 或 `category` 控制:
2576
+ - 需要中文:`source` 选「综合句子语料库 / 曹星宇句子集」,或 `category` 选中文分类(如 影视、文学、诗词)。
2577
+ - 需要英文:`source` 选「Quotable / 英文历史名言」。
2578
+
2579
+ ## 使用须知
2580
+ > [!NOTE]
2581
+ > - `source`、`category`、`tag` 支持多值,用英文逗号 `,` 或分号 `;` 分隔。
2582
+ > - `scene` 仅在 `mode=recommend` 时生效且必填,其他模式下会被忽略。
2583
+ > - 请求示例:
2584
+ > - 随机:`GET /api/v1/saying/random`
2585
+ > - 每日:`GET /api/v1/saying/random?mode=daily`
2586
+ > - 场景:`GET /api/v1/saying/random?mode=recommend&scene=night`
2587
+ > - 此刻:`GET /api/v1/saying/random?mode=moment`
2588
+ """
2589
+ params = {}
2590
+ body = {}
2591
+
2592
+ if "query" == "query" and "mode" in kwargs:
2593
+ params["mode"] = kwargs["mode"]
2594
+
2595
+ if "query" == "query" and "scene" in kwargs:
2596
+ params["scene"] = kwargs["scene"]
2597
+
2598
+ if "query" == "query" and "source" in kwargs:
2599
+ params["source"] = kwargs["source"]
2600
+
2601
+ if "query" == "query" and "category" in kwargs:
2602
+ params["category"] = kwargs["category"]
2603
+
2604
+ if "query" == "query" and "tag" in kwargs:
2605
+ params["tag"] = kwargs["tag"]
2606
+
2607
+ if "_t" in kwargs:
2608
+ params["_t"] = kwargs["_t"]
2609
+ disable_cache = kwargs.get("disable_cache")
2610
+ if disable_cache is None and "disableCache" in kwargs:
2611
+ disable_cache = kwargs["disableCache"]
2612
+ path = "/api/v1/saying/random"
2613
+
2614
+ return self._http.request(
2615
+ "GET",
2616
+ path,
2617
+ params=params,
2618
+ json=body if body else None,
2619
+ disable_cache=_coerce_optional_bool(disable_cache),
2620
+ )
2621
+
2203
2622
 
2204
2623
  class _RandomApi:
2205
2624
  def __init__(self, http: _HTTP):
@@ -2212,15 +2631,6 @@ class _RandomApi:
2212
2631
 
2213
2632
  ## 功能概述
2214
2633
  通过向答案之书提问,你将获得一个充满智慧(或许)的随机答案。这个API支持通过查询参数或POST请求体两种方式提问。
2215
-
2216
- ## 使用须知
2217
-
2218
- > [!TIP]
2219
- > **提问技巧**
2220
- > - 提出明确的问题会获得更好的体验
2221
- > - 问题不能为空
2222
- > - 支持中文问题
2223
- > - 答案具有随机性,仅供娱乐参考
2224
2634
  """
2225
2635
  params = {}
2226
2636
  body = {}
@@ -2448,6 +2858,15 @@ class _SocialApi:
2448
2858
  if "query" == "query" and "org" in kwargs:
2449
2859
  params["org"] = kwargs["org"]
2450
2860
 
2861
+ if "query" == "query" and "pinned" in kwargs:
2862
+ params["pinned"] = kwargs["pinned"]
2863
+
2864
+ if "query" == "query" and "repos" in kwargs:
2865
+ params["repos"] = kwargs["repos"]
2866
+
2867
+ if "query" == "query" and "repos_limit" in kwargs:
2868
+ params["repos_limit"] = kwargs["repos_limit"]
2869
+
2451
2870
  if "_t" in kwargs:
2452
2871
  params["_t"] = kwargs["_t"]
2453
2872
  disable_cache = kwargs.get("disable_cache")
@@ -3936,3 +4355,253 @@ UAPI Pro Search 可以根据查询内容返回更相关的搜索结果。你可
3936
4355
  )
3937
4356
 
3938
4357
 
4358
+ class _ShuiYinYuAigcBiaoShiApi:
4359
+ def __init__(self, http: _HTTP):
4360
+ self._http = http
4361
+
4362
+
4363
+ def post_watermark_decode(self, **kwargs):
4364
+ r"""提取图片隐水印
4365
+ 遇到一张疑似被盗用或 AI 生成的图片,想查查它有没有被打过“思想钢印”?直接把图片扔给这个接口,它能把藏在里面的标识完完整整地提取出来。
4366
+
4367
+ ## 功能概述
4368
+ 此接口用于检测图片中是否包含隐形水印,若存在则还原出写入的原始标识内容。即使图片经历过压缩、截取或多次网络转发,也具备较高的成功提取率。接口具备防误判机制,若图片确实未经过处理,会明确返回未检测到结果,而不会强制拼接无效内容。
4369
+
4370
+ ## 使用须知
4371
+ 如果您在嵌入水印时修改过进阶参数(如 `ecc` 或 `model_type`),在提取时必须传入相同的参数值。若嵌入时使用的是默认配置,此处直接留空即可。
4372
+ """
4373
+ params = {}
4374
+ data = {}
4375
+ files = {}
4376
+
4377
+ if "_t" in kwargs:
4378
+ params["_t"] = kwargs["_t"]
4379
+
4380
+ if "ecc" in kwargs:
4381
+ data["ecc"] = _stringify_form_value(kwargs["ecc"])
4382
+
4383
+ if "file" in kwargs:
4384
+ files["file"] = _prepare_file_value(kwargs["file"])
4385
+
4386
+ if "image_base64" in kwargs:
4387
+ data["image_base64"] = _stringify_form_value(kwargs["image_base64"])
4388
+
4389
+ if "model_type" in kwargs:
4390
+ data["model_type"] = _stringify_form_value(kwargs["model_type"])
4391
+
4392
+ if "url" in kwargs:
4393
+ data["url"] = _stringify_form_value(kwargs["url"])
4394
+
4395
+ disable_cache = kwargs.get("disable_cache")
4396
+ if disable_cache is None and "disableCache" in kwargs:
4397
+ disable_cache = kwargs["disableCache"]
4398
+ path = "/api/v1/watermark/decode"
4399
+
4400
+ return self._http.request(
4401
+ "POST",
4402
+ path,
4403
+ params=params,
4404
+ data=data or None,
4405
+ files=files or None,
4406
+ disable_cache=_coerce_optional_bool(disable_cache),
4407
+ )
4408
+
4409
+ def post_watermark_embed(self, **kwargs):
4410
+ r"""添加图片隐水印
4411
+ 想给自己的原创图片打上专属烙印,又不想破坏画面美感?或者是为了 AIGC 生成的图片做后续溯源追踪?这个接口能帮您把自定义标识悄悄藏进图片里。
4412
+
4413
+ ## 功能概述
4414
+ 您可以上传图片并指定一段标识文本,接口会利用算法将这段文本隐形嵌入到图片的像素之中。嵌入后的图片在肉眼看来毫无变化,但能够有效抵抗常见的缩放、裁剪、社交平台压缩与二次转发。适合用于标记图片来源、追踪分发渠道或进行隐蔽的版权确权。
4415
+
4416
+ ## 使用须知
4417
+ **容量限制**:受限于隐形水印的算法特性,图片能嵌入的字符长度有限(通常为短码)。建议只放入简短的溯源 ID 或特征码,将完整的映射信息存储在您自己的数据库中。
4418
+
4419
+ **参数说明**:提供图片的方式(`file` / `url` / `image_base64`)三选一即可;其他进阶参数如无特殊需求,建议保持留空使用默认最佳配置。
4420
+ """
4421
+ params = {}
4422
+ data = {}
4423
+ files = {}
4424
+
4425
+ if "_t" in kwargs:
4426
+ params["_t"] = kwargs["_t"]
4427
+
4428
+ if "ecc" in kwargs:
4429
+ data["ecc"] = _stringify_form_value(kwargs["ecc"])
4430
+
4431
+ if "file" in kwargs:
4432
+ files["file"] = _prepare_file_value(kwargs["file"])
4433
+
4434
+ if "image_base64" in kwargs:
4435
+ data["image_base64"] = _stringify_form_value(kwargs["image_base64"])
4436
+
4437
+ if "jpeg_quality" in kwargs:
4438
+ data["jpeg_quality"] = _stringify_form_value(kwargs["jpeg_quality"])
4439
+
4440
+ if "model_type" in kwargs:
4441
+ data["model_type"] = _stringify_form_value(kwargs["model_type"])
4442
+
4443
+ if "out_format" in kwargs:
4444
+ data["out_format"] = _stringify_form_value(kwargs["out_format"])
4445
+
4446
+ if "payload" in kwargs:
4447
+ data["payload"] = _stringify_form_value(kwargs["payload"])
4448
+
4449
+ if "strength" in kwargs:
4450
+ data["strength"] = _stringify_form_value(kwargs["strength"])
4451
+
4452
+ if "url" in kwargs:
4453
+ data["url"] = _stringify_form_value(kwargs["url"])
4454
+
4455
+ disable_cache = kwargs.get("disable_cache")
4456
+ if disable_cache is None and "disableCache" in kwargs:
4457
+ disable_cache = kwargs["disableCache"]
4458
+ path = "/api/v1/watermark/embed"
4459
+
4460
+ return self._http.request(
4461
+ "POST",
4462
+ path,
4463
+ params=params,
4464
+ data=data or None,
4465
+ files=files or None,
4466
+ disable_cache=_coerce_optional_bool(disable_cache),
4467
+ )
4468
+
4469
+ def post_watermark_label(self, **kwargs):
4470
+ r"""添加 AI 生成内容标识
4471
+ AI 生成的图片上线前需要满足国标合规要求?别头疼,调用一次这个接口,就能自动给图片打上符合《GB 45438-2025》标准的三层标识。
4472
+
4473
+ ## 三层标识说明
4474
+ 此接口一次性支持注入以下三种符合国标规范的标识:
4475
+ - **元数据隐式标识**(默认开启):在图片文件的 EXIF/XMP 元数据中记录此内容的“AI 生成”属性及服务提供者信息,不影响视觉呈现。
4476
+ - **可见角标标识**(可选):在图片指定角落叠加醒目的“AI 生成”文字,字号会自动计算以符合国标关于“字符高度不小于画面短边 5%”的规定。
4477
+ - **隐形水印标识**(可选):在图像像素深层嵌入抗压缩溯源信息。
4478
+
4479
+ ## 使用须知
4480
+ **必填说明**:根据规范,`content_producer`(服务提供者编码)为必填项。推荐使用本平台配套的 `/watermark/producer-code` 接口快速生成规范的 27 位服务提供者编码。
4481
+
4482
+ **标识组合**:若您需要关闭默认的元数据标识(`skip_metadata=true`),则必须至少开启可见角标或隐形水印中的一项,以保证图片拥有合规标识。
4483
+ """
4484
+ params = {}
4485
+ data = {}
4486
+ files = {}
4487
+
4488
+ if "_t" in kwargs:
4489
+ params["_t"] = kwargs["_t"]
4490
+
4491
+ if "content_producer" in kwargs:
4492
+ data["content_producer"] = _stringify_form_value(kwargs["content_producer"])
4493
+
4494
+ if "content_propagator" in kwargs:
4495
+ data["content_propagator"] = _stringify_form_value(kwargs["content_propagator"])
4496
+
4497
+ if "embed_watermark" in kwargs:
4498
+ data["embed_watermark"] = _stringify_form_value(kwargs["embed_watermark"])
4499
+
4500
+ if "explicit_height_ratio" in kwargs:
4501
+ data["explicit_height_ratio"] = _stringify_form_value(kwargs["explicit_height_ratio"])
4502
+
4503
+ if "explicit_label" in kwargs:
4504
+ data["explicit_label"] = _stringify_form_value(kwargs["explicit_label"])
4505
+
4506
+ if "explicit_position" in kwargs:
4507
+ data["explicit_position"] = _stringify_form_value(kwargs["explicit_position"])
4508
+
4509
+ if "explicit_text" in kwargs:
4510
+ data["explicit_text"] = _stringify_form_value(kwargs["explicit_text"])
4511
+
4512
+ if "file" in kwargs:
4513
+ files["file"] = _prepare_file_value(kwargs["file"])
4514
+
4515
+ if "image_base64" in kwargs:
4516
+ data["image_base64"] = _stringify_form_value(kwargs["image_base64"])
4517
+
4518
+ if "jpeg_quality" in kwargs:
4519
+ data["jpeg_quality"] = _stringify_form_value(kwargs["jpeg_quality"])
4520
+
4521
+ if "label" in kwargs:
4522
+ data["label"] = _stringify_form_value(kwargs["label"])
4523
+
4524
+ if "out_format" in kwargs:
4525
+ data["out_format"] = _stringify_form_value(kwargs["out_format"])
4526
+
4527
+ if "produce_id" in kwargs:
4528
+ data["produce_id"] = _stringify_form_value(kwargs["produce_id"])
4529
+
4530
+ if "propagate_id" in kwargs:
4531
+ data["propagate_id"] = _stringify_form_value(kwargs["propagate_id"])
4532
+
4533
+ if "skip_metadata" in kwargs:
4534
+ data["skip_metadata"] = _stringify_form_value(kwargs["skip_metadata"])
4535
+
4536
+ if "url" in kwargs:
4537
+ data["url"] = _stringify_form_value(kwargs["url"])
4538
+
4539
+ if "watermark_payload" in kwargs:
4540
+ data["watermark_payload"] = _stringify_form_value(kwargs["watermark_payload"])
4541
+
4542
+ disable_cache = kwargs.get("disable_cache")
4543
+ if disable_cache is None and "disableCache" in kwargs:
4544
+ disable_cache = kwargs["disableCache"]
4545
+ path = "/api/v1/watermark/label"
4546
+
4547
+ return self._http.request(
4548
+ "POST",
4549
+ path,
4550
+ params=params,
4551
+ data=data or None,
4552
+ files=files or None,
4553
+ disable_cache=_coerce_optional_bool(disable_cache),
4554
+ )
4555
+
4556
+ def post_watermark_producer_code(self, **kwargs):
4557
+ r"""生成 AIGC 服务提供者编码
4558
+ 还在发愁怎么拼出符合《GB 45438-2025》要求的 27 位 AIGC 服务提供者编码?无论是想一键生成自己的专属合规编码,还是想校验已有编码对不对,这个接口都能帮您轻松搞定。
4559
+
4560
+ ## 功能概述
4561
+ 此接口具备“生成”与“校验”双重能力:
4562
+ - **生成模式**:填入组织或个人的主体身份信息与证件号,接口会自动处理复杂的拼位规则,输出标准的 27 位编码。
4563
+ - **校验模式**:仅需填入现成的 `code`,接口将逐段拆解、验证其合法性,并解析出各个组成部分的实际含义。
4564
+
4565
+ ## 使用须知
4566
+ **模式互斥**:当您在请求体中填入了 `code` 参数时,接口会自动进入“校验模式”,其余的生成参数将被忽略;反之则进入“生成模式”。
4567
+
4568
+ **独立生成**:该编码不依赖向外部机构注册申请,而是基于您的法定身份标识(如企业统一社会信用代码、个人身份证等)根据标准算法独立生成即可。
4569
+ """
4570
+ params = {}
4571
+ body = {}
4572
+
4573
+ if "_t" in kwargs:
4574
+ params["_t"] = kwargs["_t"]
4575
+
4576
+ if "binding" in kwargs:
4577
+ body["binding"] = kwargs["binding"]
4578
+
4579
+ if "code" in kwargs:
4580
+ body["code"] = kwargs["code"]
4581
+
4582
+ if "identifier" in kwargs:
4583
+ body["identifier"] = kwargs["identifier"]
4584
+
4585
+ if "model_code" in kwargs:
4586
+ body["model_code"] = kwargs["model_code"]
4587
+
4588
+ if "service_type" in kwargs:
4589
+ body["service_type"] = kwargs["service_type"]
4590
+
4591
+ if "subject_type" in kwargs:
4592
+ body["subject_type"] = kwargs["subject_type"]
4593
+
4594
+ disable_cache = kwargs.get("disable_cache")
4595
+ if disable_cache is None and "disableCache" in kwargs:
4596
+ disable_cache = kwargs["disableCache"]
4597
+ path = "/api/v1/watermark/producer-code"
4598
+
4599
+ return self._http.request(
4600
+ "POST",
4601
+ path,
4602
+ params=params,
4603
+ json=body if body else None,
4604
+ disable_cache=_coerce_optional_bool(disable_cache),
4605
+ )
4606
+
4607
+
uapi/errors.py CHANGED
@@ -67,7 +67,7 @@ class UapiError(Exception):
67
67
 
68
68
  class ApiErrorError(UapiError):
69
69
  """上游/内部错误 (API_ERROR)"""
70
- DEFAULT_STATUS = 504
70
+ DEFAULT_STATUS = 503
71
71
 
72
72
  class AvatarNotFoundError(UapiError):
73
73
  """头像未找到 (AVATAR_NOT_FOUND)"""
@@ -1,16 +1,37 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uapi-sdk-python
3
- Version: 0.1.17
4
- Summary: Idiomatic UAPI SDK for Python
3
+ Version: 0.1.18
4
+ Summary: Official Python SDK for UAPI / uapis.cn — strongly-typed wrapper around 100+ free public-API endpoints (network, text, image, social, translation, search). Generated from the live OpenAPI 3.1 spec.
5
5
  Author-email: UAPI <dev@uapis.cn>
6
+ License: MIT
7
+ Project-URL: Homepage, https://uapis.cn/docs/sdk/python
8
+ Project-URL: Documentation, https://uapis.cn/docs
9
+ Project-URL: Repository, https://github.com/AxT-Team/uapi-sdk-python
10
+ Project-URL: Issues, https://github.com/AxT-Team/uapi-sdk-python/issues
11
+ Project-URL: OpenAPI Spec, https://uapis.cn/openapi.json
12
+ Keywords: uapi,uapis,uapis.cn,sdk,python,rest,rest-api,openapi,httpx,public-api,free-api,agent,ai,mcp
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Internet :: WWW/HTTP
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
6
25
  Requires-Python: >=3.9
7
26
  Description-Content-Type: text/markdown
27
+ License-File: LICENSE
8
28
  Requires-Dist: httpx>=0.24.1
9
29
  Provides-Extra: dev
10
30
  Requires-Dist: pytest; extra == "dev"
11
31
  Requires-Dist: mypy; extra == "dev"
12
32
  Requires-Dist: black; extra == "dev"
13
33
  Requires-Dist: isort; extra == "dev"
34
+ Dynamic: license-file
14
35
 
15
36
  # uapi-sdk-python
16
37
 
@@ -0,0 +1,8 @@
1
+ uapi/__init__.py,sha256=3dluUZfyWYYGTWzDBFip0d5YZej6waZiq2ayvJ0RI9o,86
2
+ uapi/client.py,sha256=VE3z6i3739zsxiN2DDA1MRIUW74YBseLSSnz7T7U2kU,181373
3
+ uapi/errors.py,sha256=eF1TI7qxHhFsTGZuSd_4CTsNj3_abWoWYIJMoTjf2CM,11067
4
+ uapi_sdk_python-0.1.18.dist-info/licenses/LICENSE,sha256=F1YYNj0coHKqNi_aOqukCoDKSdNhKEJDP6ylsgMz3pw,1072
5
+ uapi_sdk_python-0.1.18.dist-info/METADATA,sha256=NwkE2wSlOMzZqZQz02pktD47DiwwIKSZZgJLrQnyZCA,7060
6
+ uapi_sdk_python-0.1.18.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ uapi_sdk_python-0.1.18.dist-info/top_level.txt,sha256=0TrPOLLMqin88fxqxR9T5piS4dSoyju9HFiPu1oPEUU,5
8
+ uapi_sdk_python-0.1.18.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AxT-Team / UAPI
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.
@@ -1,7 +0,0 @@
1
- uapi/__init__.py,sha256=3dluUZfyWYYGTWzDBFip0d5YZej6waZiq2ayvJ0RI9o,86
2
- uapi/client.py,sha256=2MijKxsm656POod6_GZTS1fyD_7ZJdGWyjBXDanx6JY,152431
3
- uapi/errors.py,sha256=ZmB8xwqED689r4R5x4zSF7rMqZ9vUU8bwV5j_rxyHN4,11067
4
- uapi_sdk_python-0.1.17.dist-info/METADATA,sha256=pYu7jYBrvFPt6A5yVXiFyHUrP1JlLUh33ehb1Fray1Y,5848
5
- uapi_sdk_python-0.1.17.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
- uapi_sdk_python-0.1.17.dist-info/top_level.txt,sha256=0TrPOLLMqin88fxqxR9T5piS4dSoyju9HFiPu1oPEUU,5
7
- uapi_sdk_python-0.1.17.dist-info/RECORD,,