Back to your area

API access

Query nxbase programmatically with a personal token you create on your account page. A token acts with your access: admins see everything hosted, members see the public projection.

Base URL

https://enextgen.it/nxbase-api

Authentication

Send your token as a Bearer header:

Authorization: Bearer nxb_your_token_here

Endpoint

Filters (multi-value): parameter, source, commodity, activity, flow, site, period, unit… plus sort, dir, page, limit.

Python โ€” the nxbase client (recommended)

With nxbase installed, query() returns one explicit, name-resolved DataFrame โ€” item_1/item_2 already exploded into set-typed columns (commodity, activity, site, period…), roles suffixed only where a type collides. No requests, no raw CSV.

pip install nxbase   # the query env
from nxbase.client import query, gwp

API = "https://enextgen.it/nxbase-api"
TOKEN = "nxb_xxx"   # your personal token

# total production: coal vs gas in Italy and Germany
df = query(
    api_url=API, token=TOKEN,
    parameter="Total output",
    activity=["Coal", "Gas"],
    site=["Italy", "Germany"],
    sort="value", dir="desc",
)

# electricity trade mix into Italy, 2025 (role-scoped -> site_destination/site_origin)
df = query(api_url=API, token=TOKEN, parameter="Import mix", site={"destination": "Italy"}, period="2025")

# GHG footprints (CO2eq) under AR6
df = gwp(api_url=API, token=TOKEN, scheme="GHG.AR6.Y100", source="EX3318h.GHG", site="Italy")

# pivot straight off the explicit frame
df.pivot_table(index="site", columns="activity", values="value", aggfunc="sum")

Without the client โ€” curl / raw HTTP

curl -H "Authorization: Bearer nxb_xxx" \
  "https://enextgen.it/nxbase-api/query.csv?parameter=Import%20mix&period=2025"
import io, requests, pandas as pd

r = requests.get(
    "https://enextgen.it/nxbase-api/query.csv",
    params={"parameter": "Total output", "activity": ["Coal", "Gas"]},
    headers={"Authorization": "Bearer nxb_xxx"},
)
df = pd.read_csv(io.StringIO(r.text))   # already the exploded columns

Managing tokens

Create, list and revoke tokens on your account page. The full token is shown once, at creation โ€” store it then. A revoked token stops working immediately.