glovo api python开发包

glovo-api-python的Python项目详细描述


glovo python业务api

通过业务api创建、检索和跟踪glovo订单。

要求

此软件包至少需要

  • 请求2.21.0
  • Python3.7

此软件包未使用这些软件包的早期版本进行测试,但也可以正常工作。

安装

您可以通过pip安装。运行以下命令:

$ pip install glovo-api-python

凭证

在glovo中创建一个帐户(可以从应用程序中创建)。此api需要与您的帐户关联的信用卡。您可以从应用程序中添加一个,它将自动用于任何订单。为了获得您的api凭据,您应该在所需的环境中登录并转到配置文件的credentials部分。

示例ApiKey&;ApiSecret

api_key='155761234946286'api_secret='767b4e2f48e4412d95a6eb1234bdc78b'

用法

简单用法如下:

初始化客户端

fromglovo_api_python.clientimportClientapi_key='sample_api_key'api_secret='sample_api_secret'client=Client(api_key,api_secret)

获得工作区

glovo docs

woking_areas=client.working_area.list()print(working_areas)# Will show this# {#     'status': 200,#     'data': {#         'workingAreas': [#             {#                 'code': 'ABJ',#                 'polygons': [#                     '<ENCODED POLYLINE>',#                     '<ENCODED POLYLINE>'#                 ],#                 'workingTime': {#                     'from': '09:00',#                     'duration': 120#                 }#             }#             <OTHER WORKING AREAS>#         ]#     }# }

估计订单价格

glovo docs

pickup_address={"lat":-12.0563673,"lon":-76.9733736,"type":"PICKUP","label":"Avenida los Cipreses, 140","details":"Edificio Orbes, Piso 3, Oficina de Productos Angel Breña","contactPhone":None,"contactPerson":None}delivery_address={"lat":-12.055013,"lon":-77.03845849999999,"type":"DELIVERY","label":"Avenida Inca Garcilaso de la Vega, 1250","details":"Oficina 511","contactPhone":None,"contactPerson":None}estimates_order_price=client.order.estimate({"scheduleTime":None,"description":"Some useful description","addresses":[pickup_address,delivery_address]})print(estimates_order_price)# Will show this# {#     'status': 200,#     'data': {#         'total': {#             'amount': 1260,#             'currency': 'PEN'#         }#     }# }

创建订单

glovo docs

pickup_address={"lat":-12.0563673,"lon":-76.9733736,"type":"PICKUP","label":"Avenida los Cipreses, 140","details":"Edificio Orbes, Piso 3, Oficina de Productos Angel Breña","contactPhone":None,"contactPerson":None}delivery_address={"lat":-12.055013,"lon":-77.03845849999999,"type":"DELIVERY","label":"Avenida Inca Garcilaso de la Vega, 1250","details":"Oficina 511","contactPhone":None,"contactPerson":None}placed_order=client.order.create({"scheduleTime":12344566,# Set to None for immediate order"description":"Some useful description","addresses":[pickup_address,delivery_address]})print(placed_order)# Will show this# {#     'status': 200,#     'data': {#         "id": 123456789,#         "state": "SCHEDULED",#         "scheduleTime": 12344566,#         "description": "A 30cm by 30cm box",#         "addresses": [#             <PICKUP ADDRESS>,#             <DELIVERY ADDRESS>,#         ]#     }# }

检索订单

glovo docs

order_id=32678866placed_order=client.order.read(order_id)print(placed_order)# Will show this# {#     'status': 200,#     'data': {#         'scheduleTime': None,#         'description': 'Necesito enviar una llave',#         'addresses': [#             <PICKUP ADDRESS>,#             <DELIVERY ADDRESS>,#         ],#         'id': '32678866',#         'state': 'DELIVERED',#         'reference': None#     }# }

获取订单跟踪

glovo docs

order_id=32678866tracking=client.order.tracking(order_id)print(tracking)# Will show this# {#     "status": 200,#     "data": {#         "lat": -12.0704984,#         "lon": -76.9816546#     }# }

获取快递联系人

来自glovo docs

order_id=32678866courier_contact=client.order.courier_contact(order_id)print(courier_contact)# Will show this# {#     "status": 200,#     "data": {#         "courierName": "Courier names",#         "phone": "+99999999999"#     }# }

获得订单

glovo docs

start=12344566end=12544566order_list=client.order.list(data={'from':start,'to':end})print(order_list)# Will show this# {#     "status": 200,#     "data": [#         {#             "scheduleTime": null,#             "description": "Useful description!",#             "addresses": [#                 <PICKUP ADDRESS>,#                 <DELIVERY ADDRESS>,#             ],#             "id": "40304538",#             "state": "DELIVERED",#             "reference": null#         },#         <OTHER ORDERS>#     ]# }

取消订单

来自glovo docs

order_id=32678866canceled_order=client.order.cancel(order_id)print(courier_contact)# Will show this# {#     status: 200,#     data: {#         "id": 32678866,#         "state": "CANCELED",#         "scheduleTime": 12344566,#         "description": "A 30cm by 30cm box",#         "addresses": [#             <PICKUP ADDRESS>,#             <DELIVERY ADDRESS>,#         ]#     }# }

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
多线程Java易失性和可见性   如何正确组合循环(Java)?   java在外部库中设置CDI   java使用enum类方法中类的HashSet   java如何整理节点或文档字段?   是否在java中接受的方法调用中传递“this”   安卓无法bluid cordova应用程序:JDK的java需求检查失败   java从Spring更新web UI   java巨大的分配:如果发生巨大的分配,我如何要求jvm打印日志   java Tomcat身份验证要求重新登录,即使浏览器尚未关闭   java事务原子性与MySQL、MongoDB、RabbitMQ   java什么导致RTTI违反OpenClosed原则?   java将ISBN10转换为ISBN13   在MacOS X上用Eclipse Mars远程调试Tomcat 7   java在安卓中添加自定义框架   java Android在文件中写入最后一个值   java我想比较ArrayList<Player>数组中的每个元素和int[]数组   由@Version annotated int不递增引起的java OptimisticLockException   java SpelEvaluationException:EL1008E:在Thymeleaf应用程序中