Skip to main content

dchub — Python SDK for DC Hub

PyPI Python License: MIT

Live data-center and energy intelligence for AI agents. Query DC Hub instead of guessing from stale training data: facilities, markets (Data Center Power Index / DCPI), real-time ISO grid telemetry, interconnection queues, fiber, gas, site risk and tracked deals.

Four ways in, one package:

You want Use
Plain Python calls over the REST API dchub.DCHub
Any MCP tool from Python dchub.DCHubMCP (module dchub.mcp)
DC Hub tools inside your own MCP server dchub.compose.dchub_tool_definitions
LangChain or smolagents tools dchub_langchain_tools(), dchub_smolagents_tools()

Anonymous use returns previews and needs no key. A free key raises limits and unlocks full answers: claim one at https://dchub.cloud/signup or with the MCP claim_free_key tool.

Install

pip install dchub                 # core (requests only)
pip install "dchub[langchain]"    # + LangChain StructuredTools
pip install "dchub[agents]"       # + smolagents Tools

REST client

from dchub import DCHub

dc = DCHub()                              # no key
# dc = DCHub(api_key="dch_live_...")      # higher limits / key-gated endpoints

rank = dc.get_market_dcpi_rank("phoenix")
print(rank["composite_score"], rank["verdict"])

dc.search_facilities(country="US", limit=5)       # GET /api/v1/facilities
dc.stats()                                        # facility counts + sources
dc.ai_capacity_index(horizon=90)                  # AI Capacity Index markets
dc.get_grid_intelligence("PJM")                   # real-time ISO grid intel
dc.get_changes(since="24h")                       # incremental diffs

Every method returns parsed JSON (a dict). Non-2xx responses raise DCHubError, which carries .status_code and the API's self-correcting .detail (for example, how to claim a free key).

Any REST-backed tool in dchub.TOOL_MANIFEST can be called by name; path placeholders are filled from kwargs and the rest become the query string:

dc.call("get_market_dcpi_rank", slug="phoenix")
dc.call("search_facilities", provider="Equinix", limit=3)
Method REST endpoint
stats() /api/v1/stats
search_facilities(**filters) /api/v1/facilities
get_facility(slug) /api/v1/facilities/<slug>
fetch_facility(id) /api/v1/facility/<id> (numeric id)
get_market_dcpi_rank(market_slug) /api/v1/dcpi/scores/<slug>
rank_markets(by=...) /api/v1/mcp/tools/rank_markets
ai_capacity_index(horizon=90) /api/v1/ai-capacity-index
get_changes(since="24h") /api/v1/changes/since
get_grid_intelligence(iso) /api/v1/grid/intelligence/<iso>
list_transactions(**f) /api/v1/deals
get_news(**f) /api/news
get_pipeline(**f) /api/v1/pipeline (needs a free key)

MCP client (new in 0.3.0)

Every tool on the DC Hub MCP server, with the MCP handshake and SSE parsing handled (stdlib only, no extra dependencies):

from dchub import DCHubMCP

dc = DCHubMCP()                            # reads DCHUB_API_KEY from env if set
dc.market("northern-virginia")             # get_market_intel
dc.search(state="VA")                      # search_facilities
dc.grid(iso="ERCOT")                       # get_grid_data
dc.call("get_power_availability_timeline", state="TX")   # any tool
dc.tools()                                 # tool names

Compose DC Hub into your own MCP server (new in 0.3.0)

from dchub.compose import dchub_tool_definitions

defs = dchub_tool_definitions(via="acme-energy")   # 5 starter tools; tools="all" for every tool
# register each {name, description, inputSchema} in your low-level
# mcp.server.lowlevel.Server list_tools handler, and route call_tool to defs[i]["call"](arguments)

Descriptions are prefixed "From DC Hub (dchub.cloud):" and results pass through unchanged (cite_as, as_of, human_url intact). via names your server in DC Hub's per-partner counts: https://dchub.cloud/mcp/builders. Node version and the rules that come with the data: sdk/COMPOSE.md.

LangChain

from dchub import dchub_langchain_tools

tools = dchub_langchain_tools()          # list[StructuredTool]

smolagents

from dchub import dchub_smolagents_tools
from smolagents import CodeAgent, InferenceClientModel

agent = CodeAgent(tools=dchub_smolagents_tools(), model=InferenceClientModel())
agent.run("What's the DCPI verdict for Phoenix and which US market ranks #1?")

Citation

Cite data from this SDK as DC Hub (dchub.cloud), as of .

Tests and release

pip install -e ".[test]" && pytest tests/test_compose.py tests/test_published_api.py   # offline
pytest tests/test_client.py tests/test_rest_smoke.py                                   # live
python -m build && twine upload dist/*

License

MIT.

Metadata

Release files for dchub 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dchub 0.3.1
File Size Uploaded Provenance Actions
dchub-0.3.1.tar.gz 20.3 kB Without provenance Details for dchub-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dchub 0.3.1
File Interpreter ABI Platform Actions
dchub-0.3.1-py3-none-any.whl Python 3 none any Details for dchub-0.3.1-py3-none-any.whl

Total release size: 37.8 kB

Release files / dchub-0.3.1.tar.gz

Download URL dchub-0.3.1.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f9ae3cd2b0804a13b12b9177d4bec85631c57a437bb7631dfa42f4aff6915959
BLAKE2b-256 checksum
How to use checksums
dac453dd8c24480655bb526295dec17b46527bc9454bbf5e5dc524f4493ca2a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / dchub-0.3.1-py3-none-any.whl

Download URL dchub-0.3.1-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfbfe2c7eeca48e3435e89f2564b323864dfa927fa42c80e2f69b7d0e1371b52
BLAKE2b-256 checksum
How to use checksums
80cad1363987c792ed2bc3b612de7f9f6997587ab16f1f8a99d0d383002fe37e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for dchub 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page