> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-vector.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Topics

<Info>
  You can run the async code by importing `Client` from `upstash_qstash.asyncio`
  and awaiting the methods.
</Info>

#### Create a topic and add 2 endpoints

```python
from upstash_qstash import Client

client = Client("<QSTASH_TOKEN>")
topics = client.topics()
topics.upsert_or_add_endpoints(
  {
    "name": "topic_name",
    "endpoints": [
      {"url": "https://my-endpoint-1"},
      {"url": "https://my-endpoint-2"}
    ],
  }
)
```

#### Get topic by name

```python
from upstash_qstash import Client

client = Client("<QSTASH_TOKEN>")
topics = client.topics()
topic = topics.get("topic_name")
print(topic["name"], topic["endpoints"])
```

#### List topics

```python
from upstash_qstash import Client

client = Client("<QSTASH_TOKEN>")
topics = client.topics()
all_topics = topics.list()
for topic in all_topics:
  print(topic["name"], topic["endpoints"])
```

#### Remove an endpoint from a topic

```python
from upstash_qstash import Client

client = Client("<QSTASH_TOKEN>")
topics = client.topics()
topics.remove_endpoints(
  {
    "name": "topic_name",
    "endpoints": [
      {"url": "https://my-endpoint-1"},
    ],
  }
)
```

#### Delete a topic

```python
from upstash_qstash import Client

client = Client("<QSTASH_TOKEN>")
topics = client.topics()
topics.delete("topic_name")
```
