├── .gitignore ├── goods_cities_mapper.example.json ├── README.API.md ├── README.md └── sorter.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | *csv 4 | -------------------------------------------------------------------------------- /goods_cities_mapper.example.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "__comment__": "请通过调用api获取数据并与游戏中数据比对后,填写如下数据", 4 | "id": "a1b2c3d4e5f6", 5 | "name": "测试商品", 6 | "station": "测试站点" 7 | } 8 | ] -------------------------------------------------------------------------------- /README.API.md: -------------------------------------------------------------------------------- 1 | ## GET /api/fetch/goods_info 2 | 3 | 此接口为通用数据获取接口。 4 | 5 | ##### 请求参数 6 | 7 | | 参数名 | 类型 | 位置 | 描述 | 是否必需 | 8 | | ------- | ------ | ----- | -------------------------------------- | -------- | 9 | | station | string | query | 筛选条件 站点名(中文,如“7号自由港”) | 否 | 10 | | good | string | query | 筛选条件 商品名(中文,如“发动机”) | 否 | 11 | | uuid | string | query | 鉴权 UUID | 是 | 12 | 13 | ##### 返回参数 14 | 15 | | 参数名 | 类型 | 描述 | 16 | | ------------------ | ------ | ------------------------------------------ | 17 | | [object] | array | 商品信息数组 | 18 | | > name | string | 商品名(中文,如“发动机”) | 19 | | > station | string | 站点名(中文,如“7号自由港”) | 20 | | > stock | number | 基础货量 | 21 | | > type | string | 交易类型(buy为站点收购,sell为站点出售) | 22 | | > base_price | number | 基础价格 | 23 | | > price | number | 当前价格 | 24 | | > next_trend | number | 下次价格变化趋势(> 0 则上涨,< 0 则下降) | 25 | | > update_time | string | 更新时间(UTC +0; yyyy-MM-dd HH:mm:ss) | 26 | | > update_timestamp | number | 更新时间(UTC +0; Unix时间戳) | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 雷索纳斯 商品数据 API 2 | 3 | ![ResoData API](https://healthchecks.io/b/2/87bd357a-8ba7-4a98-a89d-5de75054a15f.svg) 4 | 5 | 来自索思学会的神秘情报商人研制的奇怪API。通过调用这个API,能够获得一些包含商品信息的数据,似乎是交易所的物品价格和趋势? 6 | 7 | ## 接口地址 8 | 9 | 索思学会提供的API地址:[https://reso-data.kmou424.moe/](https://reso-data.kmou424.moe/) 10 | 11 | ## 授权 12 | 13 | 只有通过学会考核的人才能使用 API,关于学会的考核,可以透露一些小道消息,候选者必须满足以下要求: 14 | 15 | 1. 不能利用数据做坏事,比如破坏商会秩序,干扰正常交易。 16 | 2. 要使用数据做对列车长们有好处的事,不可倒卖数据骗取列车长们的铁盟币。 17 | 3. 需要在使用处作为数据来源标明本仓库地址,但不要四处宣传数据或是学会。 18 | 4. 不要在短时间内大量获取数据。 19 | 20 | 如果违反了上面的要求,学会很有可能会**取消**你的使用权哦。 21 | 22 | 如果候选者满足了以上的要求,发送考核申请书到代理人 [我](mailto:me@kmou424.moe) 的邮箱里,并加入 QQ 群(转到页面底部)。 23 | 24 | 我将会转发给协会的神秘情报商人,并把审核结果发送回你的邮箱里。 25 | 26 | 学会要求需要在申请书里详细说明你获取数据的用途以及你加入 QQ 群的账号哦(用于核对)。 27 | 28 | ### API 文档 29 | 30 | [API 参考](README.API.md) 31 | 32 | ### 更多 33 | 34 | 神秘情报商人告诉我们,我们只需要派人到各个站点和他们对接,情报员就会**每分钟**一次地送来当地交易所的价格变动情报。 35 | 36 | 由于我们的情报员不够专业,所以只能派出到部分站点: 37 | 38 | - [x] 修格里城 39 | - [x] 铁盟哨站 40 | - [x] 7号自由港 41 | - [x] 澄明数据中心 42 | - [x] 阿妮塔战备工厂(需要lv.40的情报员)(Thanks [@bw0963](https://github.com/bw0963)) 43 | - [x] 阿妮塔能源研究所 44 | - [x] 阿妮塔发射中心(Thanks [@bw0963](https://github.com/bw0963)) 45 | - [x] 荒原站 46 | - [x] 曼德矿场 47 | - [x] 淘金乐园 48 | - [x] 海角城 49 | 50 | 欢迎介绍更多的专业情报员来帮助我们收集情报。 51 | 52 | ## 参与贡献 53 | 54 | 提出改进建议/功能请求:在项目的 issues 页面中发起一个 issue,标题按照`[类型] 标题`的格式来编写,类型包含:建议、功能请求、BUG。在提交 Pull Request 和 Issue 前,请确保遵守规范。 55 | 56 | ## 联系我 57 | 58 | - QQ群:493153096 59 | 60 | -------------------------------------------------------------------------------- /sorter.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | 4 | from collections import defaultdict 5 | from pypinyin import pinyin, Style 6 | 7 | 8 | def main(): 9 | parser = argparse.ArgumentParser(description='Process JSON data with comments') 10 | parser.add_argument('-f', '--file', type=str, help='Input file path') 11 | parser.add_argument('-s', '--sort_key', type=str, default='name', help='Key to sort the data') 12 | parser.add_argument('-g', '--group_key', type=str, default='station', help='Key to group the data') 13 | parser.add_argument('-o', '--output', type=str, help='Output file name') 14 | 15 | args = parser.parse_args() 16 | 17 | with open(args.file, "r", encoding='utf-8') as file: 18 | json_data_str = file.read() 19 | parsed_json_data = json.loads(json_data_str) 20 | 21 | existed_keys = [] 22 | json_data = [] 23 | for ele in parsed_json_data: 24 | if isinstance(ele, dict): 25 | if ele['id'] in existed_keys: 26 | continue 27 | json_data.append(ele) 28 | existed_keys.append(ele['id']) 29 | 30 | sorted_data = sorted(json_data, key=lambda x: pinyin(x.get(args.sort_key), style=Style.NORMAL)) 31 | 32 | grouped_data = defaultdict(list) 33 | for item in sorted_data: 34 | grouped_data[item[args.group_key]].append(item) 35 | 36 | sorted_grouped_data = dict(sorted(grouped_data.items(), key=lambda x: x[0])) 37 | 38 | output_json = [] 39 | 40 | for group_key, group in sorted_grouped_data.items(): 41 | output_json.append("-" * 15 + group_key + "-" * 14 + ">") 42 | output_json.extend(group) 43 | output_json.append("<" + "-" * 14 + group_key + "-" * 15) 44 | 45 | output_json_str = json.dumps(output_json, ensure_ascii=False, indent=2, separators=(',', ': ')) 46 | 47 | if args.output: 48 | output_file = args.output 49 | else: 50 | output_file = args.file.replace('.json', '_out.json') 51 | 52 | with open(output_file, 'w', encoding='utf-8') as outfile: 53 | outfile.write(output_json_str) 54 | 55 | 56 | if __name__ == "__main__": 57 | main() 58 | --------------------------------------------------------------------------------