{"id":20983185,"url":"https://github.com/deanthompson/pyelong","last_synced_at":"2026-04-11T08:44:35.333Z","repository":{"id":33932192,"uuid":"37655113","full_name":"DeanThompson/pyelong","owner":"DeanThompson","description":"Python SDK for Elong OpenAPI.","archived":false,"fork":false,"pushed_at":"2019-10-02T21:36:29.000Z","size":50,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T07:08:02.242Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeanThompson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-18T11:17:20.000Z","updated_at":"2016-01-26T03:35:38.000Z","dependencies_parsed_at":"2022-07-13T14:32:43.250Z","dependency_job_id":null,"html_url":"https://github.com/DeanThompson/pyelong","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeanThompson%2Fpyelong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeanThompson%2Fpyelong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeanThompson%2Fpyelong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeanThompson%2Fpyelong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeanThompson","download_url":"https://codeload.github.com/DeanThompson/pyelong/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243392281,"owners_count":20283559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T05:48:05.018Z","updated_at":"2025-12-26T08:22:06.026Z","avatar_url":"https://github.com/DeanThompson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyelong\n=======\n\n[艺龙 API](http://open.elong.com/wiki/API%E6%96%87%E6%A1%A3) 的 Python 封装。\n\n参考了 @icyleaf 的这个项目：[https://github.com/icyleaf/elong/](https://github.com/icyleaf/elong/)\n\n## 特点\n\n- 支持国内酒店(hotel)／国际酒店(ihotel)等所有 API\n- 自动选择 HTTP／HTTPS\n- 计算签名、生成请求链接\n- 使用简单，调用参数与文档保持一致\n- 支持同步（requests）和 Tornado 异步（AsyncHTTPClient, coroutine）\n- 有信用卡加密方法\n- requests 请求支持简单的基于 HTTP 状态码和 API 错误码的重试\n- 支持使用代理\n\n## 不支持\n\n- 没有针对 API 做参数检查\n- 不支持 xml 格式的请求和返回值\n\n## 安装\n\n用 pip 安装：\n\n```bash\npip install pyelong\n```\n\n或者：\n\n```bash\npip install -e git+https://github.com/DeanThompson/pyelong.git@master#egg=pyelong\n```\n\n也可以通过源码安装：\n\n```bash\ngit clone git@github.com:DeanThompson/pyelong.git\ncd pyelong\npython setup.py install\n```\n\n依赖:\n\n- [requests](http://docs.python-requests.org/en/latest/)\n- [Tornado](http://www.tornadoweb.org/en/stable/)\n- [pycrypto](https://www.dlitz.net/software/pycrypto/)\n\n## 使用\n\n假设已经在艺龙注册了 API 用户，得到了 `user`, `app_key`, `secret_key`，并且 IP 已经在艺龙的白名单里。\n\n### 初始化一个客户端 `client`\n\n```python\nfrom pyelong import Client\n\nclient = Client(user=user, app_key=app_key, secret_key=secret_key)\n\n# 初始化 client 时还可以传入：\n#\n# host: 指定 API 的 host，在开发时最好指定测试环境的 host\n# local: 语言\n# version: API 版本，默认 1.1\n# use_tornado: 是否适配 Tornado\n# cert: SSL 证书文件路径，如果不指定不会进行证书检查\n```\n\n### 调用\n\n```python\nresponse = client.hotel.list(ArrivalDate='06/24/2015', DepartureDate='06/25/2015', CityId='0101')\n\n# HTTP 状态码\nprint response.status_code\n\n# API 状态码\nprint response.code\n\n# API 错误\nprint response.error\n\n# API 返回结果，是一个 json 对象\nprint response.result\n\n# print response\n```\n\n## 与 Tornado 一起使用\n\n```python\nfrom tornado.web import RequestHandler, Application\nfrom tornado import gen, ioloop, options\n\nfrom pyelong import Client\n\nclient = Client(\n    user=user,\n    app_key=app_key,\n    secret_key=secret_key,\n    host='api.test.lohoo.com/rest',  # 测试环境\n    use_tornado=True   # 显示设置为 True，使用 AsyncHTTPClient\n)\n\nclass HotelListHandler(RequestHandler):\n    @gen.coroutine\n    def get():\n        resp = yield client.hotel.list(ArrivalDate='06/24/2015',\n                                       DepartureDate='06/25/2015',\n                                       CityId='0101')\n        self.write(resp.to_json())\n\n\napplication = Application([\n    (r'/hotel/list', HotelListHandler)\n])\n\nif __name__ == '__main__':\n    application.listen(9999)\n    ioloop.IOLoop().instance().start()\n```\n\n## 注意\n\n由于个人使用原因，主要维护更新国际酒店的接口，其他功能未在生产环境中得到验证。\n\n## LICENSE\n\n[The MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeanthompson%2Fpyelong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeanthompson%2Fpyelong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeanthompson%2Fpyelong/lists"}