{"id":5243,"library":"grpc-requests","title":"grpc-requests: gRPC for Humans","description":"grpc-requests is a Python library that simplifies interaction with gRPC services, especially those that implement gRPC reflection. It aims to provide a `requests`-like API for gRPC, abstracting away much of the boilerplate associated with standard gRPC client code, allowing for more dynamic interaction without pre-generated stubs. The current version is 0.1.21, with a regular release cadence addressing compatibility, bug fixes, and new features.","status":"active","version":"0.1.21","language":"en","source_language":"en","source_url":"https://github.com/grpc-requests/grpc_requests","tags":["grpc","client","reflection","protobuf","rpc","asyncio"],"install":[{"cmd":"pip install grpc-requests","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core gRPC runtime for Python.","package":"grpcio","optional":false},{"reason":"Provides gRPC server reflection capabilities, which is a primary feature of grpc-requests.","package":"grpcio-reflection","optional":false},{"reason":"Protocol Buffers library for message serialization and deserialization.","package":"protobuf","optional":false}],"imports":[{"note":"For synchronous gRPC client interactions using reflection.","symbol":"Client","correct":"from grpc_requests import Client"},{"note":"For asynchronous gRPC client interactions using reflection.","symbol":"AsyncClient","correct":"from grpc_requests.aio import AsyncClient"},{"note":"Used when gRPC reflection is not available, requiring pre-defined service descriptors.","symbol":"StubClient","correct":"from grpc_requests import StubClient"}],"quickstart":{"code":"import os\nfrom grpc_requests import Client\n\n# Replace with your gRPC server endpoint (e.g., 'localhost:50051')\n# Ensure your gRPC server has reflection enabled.\nGRPC_SERVER_ENDPOINT = os.environ.get('GRPC_SERVER_ENDPOINT', 'localhost:50051')\n\n# Example: If your server requires TLS\n# client = Client.get_by_endpoint(GRPC_SERVER_ENDPOINT, ssl=True)\n\nclient = Client.get_by_endpoint(GRPC_SERVER_ENDPOINT)\n\nprint(f\"Connected to gRPC server at {GRPC_SERVER_ENDPOINT}\")\n\n# Assuming a 'helloworld.Greeter' service with a 'SayHello' method\n# and that the server supports reflection and this service.\ntry:\n    service_names = client.service_names\n    if 'helloworld.Greeter' in service_names:\n        print(f\"Available services: {service_names}\")\n        request_data = {\"name\": \"World\"}\n        response = client.request(\"helloworld.Greeter\", \"SayHello\", request_data)\n        print(f\"Response from SayHello: {response}\")\n    else:\n        print(\"helloworld.Greeter service not found on the server.\")\nexcept Exception as e:\n    print(f\"Error interacting with gRPC server: {e}\")\n    print(\"Ensure a gRPC server with reflection is running at the specified endpoint and 'helloworld.Greeter' service is available.\")\n","lang":"python","description":"This quickstart demonstrates how to create a synchronous gRPC client using `grpc-requests` to interact with a server via reflection. It connects to a specified endpoint, retrieves available service names, and then makes a `SayHello` RPC call to a 'helloworld.Greeter' service. This requires a running gRPC server with reflection enabled and the 'helloworld.Greeter' service implemented."},"warnings":[{"fix":"Upgrade Python to 3.8 or newer.","message":"Support for Python 3.7 was removed in version 0.1.19. Users on Python 3.7 or older must upgrade their Python version to use recent grpc-requests releases.","severity":"breaking","affected_versions":">=0.1.19"},{"fix":"Ensure the gRPC server is configured to enable reflection. Alternatively, use `StubClient` if you have pre-generated `.proto` stubs.","message":"The primary `Client` functionality of `grpc-requests` relies heavily on gRPC Server Reflection. If the target gRPC server does not have reflection enabled, `grpc-requests` will not be able to discover services or methods, leading to errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully manage `protobuf`, `grpcio`, and `grpcio-reflection` versions to match documented compatibilities, especially when encountering `RuntimeError` or `ImportError` related to version mismatches. Refer to `grpc-requests`'s PyPI page or GitHub for the latest compatibility matrix.","message":"There are known compatibility issues between specific versions of `protobuf`, `grpcio`, and `grpcio-reflection`. For instance, `protobuf 4.25.4` is not compatible with `grpcio` / `grpcio-reflection >=1.66.0` (you should stick to `1.65.x`). Also, for Python 3.13, `protobuf` version `5.29.4` or above is required.","severity":"gotcha","affected_versions":"All versions, specific to dependency combinations"},{"fix":"Consult the `grpc-requests` documentation or examples for the correct handling of request data and iterating over responses for different streaming types.","message":"When dealing with gRPC streaming methods (server-streaming, client-streaming, bidirectional-streaming), the interaction pattern with `grpc-requests` differs. For client-streaming, you typically pass an iterable of request messages. For server-streaming or bidirectional-streaming, the response will be an iterator of response messages.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}