{"id":13549682,"url":"https://github.com/googleapis/python-pubsub","last_synced_at":"2025-05-13T18:11:28.310Z","repository":{"id":37970532,"uuid":"226992581","full_name":"googleapis/python-pubsub","owner":"googleapis","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-28T21:01:40.000Z","size":6149,"stargazers_count":404,"open_issues_count":50,"forks_count":206,"subscribers_count":52,"default_branch":"main","last_synced_at":"2025-05-03T06:45:15.828Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googleapis.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-10T00:09:52.000Z","updated_at":"2025-05-02T00:05:35.000Z","dependencies_parsed_at":"2024-01-12T00:35:27.691Z","dependency_job_id":"61c3d7e5-5c2c-446e-9c5c-0bf3cb3fd3f2","html_url":"https://github.com/googleapis/python-pubsub","commit_stats":{"total_commits":1140,"total_committers":82,"mean_commits":"13.902439024390244","dds":0.881578947368421,"last_synced_commit":"f79d35a21a0e005613f1f80f8ad285da5af09abb"},"previous_names":[],"tags_count":141,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fpython-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fpython-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fpython-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fpython-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googleapis","download_url":"https://codeload.github.com/googleapis/python-pubsub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000854,"owners_count":21997442,"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-08-01T12:01:24.391Z","updated_at":"2025-05-13T18:11:28.275Z","avatar_url":"https://github.com/googleapis.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Python Client for Google Cloud Pub / Sub\n========================================\n\n|GA| |pypi| |versions| \n\n`Google Cloud Pub / Sub`_ is a fully-managed real-time messaging service that\nallows you to send and receive messages between independent applications. You\ncan leverage Cloud Pub/Sub’s flexibility to decouple systems and components\nhosted on Google Cloud Platform or elsewhere on the Internet. By building on\nthe same technology Google uses, Cloud Pub / Sub is designed to provide “at\nleast once” delivery at low latency with on-demand scalability to 1 million\nmessages per second (and beyond).\n\nPublisher applications can send messages to a ``topic`` and other applications\ncan subscribe to that topic to receive the messages. By decoupling senders and\nreceivers, Google Cloud Pub/Sub allows developers to communicate between\nindependently written applications.\n\n- `Product Documentation`_\n- `Client Library Documentation`_\n\n.. |GA| image:: https://img.shields.io/badge/support-GA-gold.svg\n   :target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#general-availability\n.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-pubsub.svg\n   :target: https://pypi.org/project/google-cloud-pubsub/\n.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-pubsub.svg\n   :target: https://pypi.org/project/google-cloud-pubsub/\n.. _Google Cloud Pub / Sub: https://cloud.google.com/pubsub/\n.. _Product Documentation: https://cloud.google.com/pubsub/docs\n.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/pubsub/latest\n\nQuick Start\n-----------\n\nIn order to use this library, you first need to go through the following steps:\n\n1. `Select or create a Cloud Platform project.`_\n2. `Enable billing for your project.`_\n3. `Enable the Google Cloud Pub / Sub API.`_\n4. `Setup Authentication.`_\n\n.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project\n.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project\n.. _Enable the Google Cloud Pub / Sub API.:  https://cloud.google.com/pubsub\n.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html\n\nInstallation\n~~~~~~~~~~~~\n\nInstall this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to\ncreate isolated Python environments. The basic problem it addresses is one of\ndependencies and versions, and indirectly permissions.\n\nWith `virtualenv`_, it's possible to install this library without needing system\ninstall permissions, and without clashing with the installed system\ndependencies.\n\n.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/\n\n\nSupported Python Versions\n^^^^^^^^^^^^^^^^^^^^^^^^^\nPython \u003e= 3.7\n\nDeprecated Python Versions\n^^^^^^^^^^^^^^^^^^^^^^^^^^\nPython \u003c= 3.6.\n\nThe last version of this library compatible with Python 2.7 is google-cloud-pubsub==1.7.0.\n\n\nMac/Linux\n^^^^^^^^^\n\n.. code-block:: console\n\n    pip install virtualenv\n    virtualenv \u003cyour-env\u003e\n    source \u003cyour-env\u003e/bin/activate\n    \u003cyour-env\u003e/bin/pip install google-cloud-pubsub\n\n\nWindows\n^^^^^^^\n\n.. code-block:: console\n\n    pip install virtualenv\n    virtualenv \u003cyour-env\u003e\n    \u003cyour-env\u003e\\Scripts\\activate\n    \u003cyour-env\u003e\\Scripts\\pip.exe install google-cloud-pubsub\n\n\nExample Usage\n~~~~~~~~~~~~~\n\nPublishing\n^^^^^^^^^^\n\nTo publish data to Cloud Pub/Sub you must create a topic, and then publish\nmessages to it\n\n.. code-block:: python\n\n    import os\n    from google.cloud import pubsub_v1\n\n    publisher = pubsub_v1.PublisherClient()\n    topic_name = 'projects/{project_id}/topics/{topic}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        topic='MY_TOPIC_NAME',  # Set this to something appropriate.\n    )\n    publisher.create_topic(name=topic_name)\n    future = publisher.publish(topic_name, b'My first message!', spam='eggs')\n    future.result()\n\nTo learn more, consult the `publishing documentation`_.\n\n.. _publishing documentation: https://cloud.google.com/python/docs/reference/pubsub/latest\n\n\nSubscribing\n^^^^^^^^^^^\n\nTo subscribe to data in Cloud Pub/Sub, you create a subscription based on\nthe topic, and subscribe to that, passing a callback function.\n\n.. code-block:: python\n\n    import os\n    from google.cloud import pubsub_v1\n\n    topic_name = 'projects/{project_id}/topics/{topic}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        topic='MY_TOPIC_NAME',  # Set this to something appropriate.\n    )\n\n    subscription_name = 'projects/{project_id}/subscriptions/{sub}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        sub='MY_SUBSCRIPTION_NAME',  # Set this to something appropriate.\n    )\n\n    def callback(message):\n        print(message.data)\n        message.ack()\n\n    with pubsub_v1.SubscriberClient() as subscriber:\n        subscriber.create_subscription(\n            name=subscription_name, topic=topic_name)  \n        future = subscriber.subscribe(subscription_name, callback)\n\nThe future returned by the call to ``subscriber.subscribe`` can be used to\nblock the current thread until a given condition obtains:\n\n.. code-block:: python\n\n    try:\n        future.result()\n    except KeyboardInterrupt:\n        future.cancel()\n\nIt is also possible to pull messages in a synchronous (blocking) fashion. To\nlearn more about subscribing, consult the `subscriber documentation`_.\n\n.. _subscriber documentation: https://cloud.google.com/python/docs/reference/pubsub/latest\n\n\nAuthentication\n^^^^^^^^^^^^^^\n\nIt is possible to specify the authentication method to use with the Pub/Sub\nclients. This can be done by providing an explicit `Credentials`_ instance. Support\nfor various authentication methods is available from the `google-auth`_ library.\n\nFor example, to use JSON Web Tokens, provide a `google.auth.jwt.Credentials`_ instance:\n\n.. code-block:: python\n\n    import json\n    from google.auth import jwt\n\n    service_account_info = json.load(open(\"service-account-info.json\"))\n    audience = \"https://pubsub.googleapis.com/google.pubsub.v1.Subscriber\"\n\n    credentials = jwt.Credentials.from_service_account_info(\n        service_account_info, audience=audience\n    )\n\n    subscriber = pubsub_v1.SubscriberClient(credentials=credentials)\n\n    # The same for the publisher, except that the \"audience\" claim needs to be adjusted\n    publisher_audience = \"https://pubsub.googleapis.com/google.pubsub.v1.Publisher\"\n    credentials_pub = credentials.with_claims(audience=publisher_audience) \n    publisher = pubsub_v1.PublisherClient(credentials=credentials_pub)\n\n.. _Credentials: https://google-auth.readthedocs.io/en/latest/reference/google.auth.credentials.html#google.auth.credentials.Credentials\n.. _google-auth: https://google-auth.readthedocs.io/en/latest/index.html\n.. _google.auth.jwt.Credentials: https://google-auth.readthedocs.io/en/latest/reference/google.auth.jwt.html#google.auth.jwt.Credentials\n\n\nVersioning\n----------\n\nThis library follows `Semantic Versioning`_.\n\nIt is currently in major version one (1.y.z), which means that the public API should be considered stable.\n\n.. _Semantic Versioning: http://semver.org/\n\nContributing\n------------\n\nContributions to this library are always welcome and highly encouraged.\n\nSee the `CONTRIBUTING doc`_ for more information on how to get started.\n\n.. _CONTRIBUTING doc: https://github.com/googleapis/google-cloud-python/blob/main/CONTRIBUTING.rst\n\nCommunity\n---------\n\nThe best place to ask questions is via Stackoverflow: https://stackoverflow.com/questions/tagged/google-cloud-pubsub\n\n\nLicense\n-------\n\nApache 2.0 - See `the LICENSE`_ for more information.\n\n.. _the LICENSE: https://github.com/googleapis/google-cloud-python/blob/main/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Fpython-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogleapis%2Fpython-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Fpython-pubsub/lists"}