# Event Livestream

If you have livestreaming enabled on an indexer for one of your projects (check the 'Stream Enabled' box in project settings: <https://docs.graffle.io/graffle-docs/graffle-management-dashboard/projects/project-indexers>), you can stream events in real time to your frontend.\
\
This is best used when you want to show live events on your site, without polling the Event Search API or your own API.&#x20;

{% hint style="info" %}
Note: You can contact us on our discord for an API key.
{% endhint %}

To get started, install the livestream SDK by running:

```
npm install @graffle/flow-livestream-sdk  
```

Then configure the SDK with your project Id and API key, and whether this is a test net project.

```
const clientConfig = {
    projectId: '<your project id>',
    apiKey: '<your api key>'
  };

const streamSDK = new GraffleSDK(clientConfig);
// or `const streamSDK = new GraffleSDK(clientConfig, true);` for test net
```

Then, create a function to display/process events as they come in and pass this function to the SDK via the `stream` method.

```
const displayEvent = (message) => {
    console.log(message);
    //display/process the event here
  };

  useEffect(() => {
    streamSDK.stream(displayEvent);
  }, []);
```

To disconnect and stop receiving events, call the `disconnect` method

```
streamSDK.disconnect();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.graffle.io/graffle-docs/apis/event-livestream.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
