When you use the Bigdata.com Chat API, every answer can be traced back to its sources. This is called inline attribution. Inline attribution helps you understand where the information comes from, providing transparency and trust in the responses.

This guide will show you how to:

✅ Install bigdata-client package
✅ Read inline attribution details
✅ Retrieve the full document
✅ Get the favicon

You can display those details in your proprietary Chatbot in the same way as Bigdata App:

Chat source details

Ready to get started? Let’s dive in!

The steps below provide code snippet examples, please refer to the section Complete script to see the complete script.

Install bigdata-client package

Follow Prerequisites instructions to set up the require environment.

Read inline attribution details

The following script will create a chat, ask a question and print the inline attribution details from the response sources.

  • headline: The title of the document.
  • id: A unique identifier for the document in Bigdata.com.
  • URL: The direct link to the source document (if available).
  • timestamp: The publication date/time of the document.
  • image_urls: A representative image from the document (if available).
from bigdata_client import Bigdata

bigdata = Bigdata()

# Create a new chat and ask a question
chat = bigdata.chat.new("Quantum Computing")
response = chat.ask(
    "What companies are researching on Quantum Computing?",
    streaming=True,
    scope=ChatScope.NEWS
)

print(f"\nDocuments used to craft the Chat response:\n")
for source in response.sources:
    print(f"\tHeadline: {source.headline}")
    print(f"\tDocument ID: {source.id}")
    print(f"\tURL: {source.url}")
    print(f"\tTimestamp: {source.timestamp}")
    print(f"\tImage URL: {source.image_urls[0] if source.image_urls else 'N/A'}")

Retrieve the full Document

If the document is an indexed Bigdata.com document, you can download the full annotated document with the following script.

    # Retrieve the full document using the Document ID
    doc_id = source.id
    documents = bigdata.search.new(query= Document(doc_id)).run(1)

    if documents:
        doc = documents[0]
    else:
        raise ValueError("Document not found")

Getting the Favicon

We need the ID of the indexed source that published the document, and use the Knowledge Graph’s get_sources method.

    # Get the source metadata with the favicon URL
    sources = bigdata.knowledge_graph.get_sources([doc.source.key])
    print(f"\tFavicon URL: {sources[0].favicon}")

Complete script

This script creates a Chat, asks a question, prints the question and the answer, and prints inline attribution details for each document used to craft the Chat response.

Then it also downloads the entire annotated document and saves it in your directory.

import os
from bigdata_client import Bigdata
from bigdata_client.models.chat import ChatScope
from bigdata_client.query import Document
import json

# Initialize Bigdata client with credentials from the environment variables.
bigdata = Bigdata()

# Create a new chat and ask a question
chat = bigdata.chat.new("Quantum Computing")
response = chat.ask(
    "What companies are researching on Quantum Computing?",
    streaming=True,
    scope=ChatScope.NEWS
)

# Print the question and the answer
print(f"\nQuestion:\n - {response.question}")
print(f"\nAnswer:")
for streamingChatInteraction in response:
  print(streamingChatInteraction, end="")

# Print the documents used to craft the Chat response
print(f"\n\nDocuments used to craft the Chat response:")
for source in response.sources:
    print(f"\n\tHeadline: {source.headline}")
    print(f"\tDocument ID: {source.id}")
    print(f"\tURL: {source.url}")
    print(f"\tTimestamp: {source.timestamp}")
    print(f"\tThumbnail image URL: {source.image_urls[0] if source.image_urls else 'N/A'}")    

    # Retrieve the full document using the Document ID
    doc_id = source.id
    documents = bigdata.search.new(query= Document(doc_id)).run(1)

    if documents:
        doc = documents[0]
    else:
        raise ValueError("Document not found")

    # Get the source metadata with the favicon URL
    sources = bigdata.knowledge_graph.get_sources([doc.source.key])
    print(f"\tFavicon URL: {sources[0].favicon}")

    # Download document with the document ID in the file name
    with open(f'annotated_doc_{doc_id}.json', 'w', encoding='utf-8') as outfile:
        json.dump(doc.download_annotated_dict(), outfile, ensure_ascii=False, indent=2)

Output:

Question:
 - What companies are researching on Quantum Computing?

Answer:
Several major technology companies and specialized firms are actively researching and developing quantum computing.

## Key Companies in Quantum Computing Research

*   **Google (Alphabet)**: Google's Quantum AI division is a significant player, having unveiled the Willow chip, which solved a benchmark computation in under five minutes that would take a supercomputer an estimated 10 septillion years. `:ref[3]`  
*   **IBM**: IBM is a leader in superconducting quantum computing and has made extensive progress in the field. `:ref[8]` `:ref[12]` `:ref[14]` `:ref[17]`  
*   **Microsoft**: Microsoft is heavily investing in quantum research and has made progress toward building scalable and practical quantum supercomputers. `:ref[1]` `:ref[10]` `:ref[19]` `:ref[6]` `:ref[14]`  
...

These companies, along with others, are driving the rapid advancement of quantum capabilities and exploring applications across various sectors, including AI, cybersecurity, and complex problem-solving. `:ref[1]` `:ref[10]` `:ref[19]` `:ref[4]` `:ref[20]` `:ref[17]`  

Documents used to craft the Chat response:

        Headline: Quantum Computing Emerging as a Transformative Technology with Potential Applications in Drone Technology
        Document ID: 73A15451DD16D78405B10E92F1641194
        URL: https://www.benzinga.com/node/46342928?utm_campaign=partner_feed&utm_medium=feed&utm_source=ravenpack
        Timestamp: 2025-07-10T13:40:01
        Thumbnail image URL: N/A
        Favicon URL: https://www.benzinga.com/next-assets/images/favicon-32x32.png

        Headline: The Quantum Threat To Encryption: How Businesses Can Future-Proof
        Document ID: D8A5610C70DA8B24C8F7A929B1722F3B
        URL: https://www.forbes.com/councils/forbesbusinesscouncil/2025/07/09/the-quantum-threat-to-encryption-how-businesses-can-future-proof/
        Timestamp: 2025-07-09T12:47:27
        Thumbnail image URL: https://specials-images.forbesimg.com/imageserve/67913b4f541319d1ba63a8a6/A-software-developer-is-thinking-on-improving-the-efficiency-of-the-AI-system/960x0.jpg
        Favicon URL: https://i.forbesimg.com/48X48-F.png

        ...

Annotated documents created in your directory:

Annotated files

Example of annotated file:

{
  "document": {
    "rp_document_id": "4CC4677A5ABBD6999B86A3C1BB90342B",
    "source": {
      "rp_source_id": "5A5702",
      "name": "Benzinga",
      "rank": 1
    },
    "timestamps_utc": {
      "published": "2025-07-10 13:15:01.000",
      "reception": "2025-07-10 13:15:04.546",
      "analytics": "2025-07-10 13:15:07.270",
      "revision": "2025-07-10 13:15:07.270"
    },
    "metadata": {
      "url": "https://www.benzinga.com/node/46342267?utm_campaign=partner_feed&utm_medium=feed&utm_source=ravenpack",
      "original_language": "en"
    }
  },
  "content": {
    "stats": {
      "byte_count": 26594,
      "word_count": 2300,
      "extraction_byte_count": 26594
    },
    "title": {
      "text": "Quantum Computing Market Witnessing Surge in Government and Private Sector Funding",
      "sentences": [...],
      "entities": [...]
    },
    "body": [...]
  },
  "analytics": {
    "document": {...},
    "events": [...],
    "entities": [...]
  }
}