API Access and Token Use
CITYNEXUS PRO API requests are authenticated with the same user session used in the CITYNEXUS PRO web interface. After logging in through the DestinE platform, the browser sends an access token to the CITYNEXUS PRO API in the HTTP Authorization header.
Get an access token
Log in to CITYNEXUS PRO through the DestinE platform.
Open the browser developer tools and select the
Networktab.Refresh CITYNEXUS PRO or open a scenario, simulation, or map view so that the application makes an API request.
Select a request whose path starts with
/api/v1/citynexus/.In the request headers, find
Authorization: Bearer <token>and copy only the<token>value.
Treat the token like a password. Do not share it, commit it to source control, or paste it into public logs. Tokens expire; if an API request returns 401 Unauthorized or 403 Forbidden, sign in again and copy a fresh token.
Use the token in an API request
Use the token as a Bearer token in the Authorization header. Replace https://<citynexus-pro-host> with the CITYNEXUS PRO host you are using.
export CITYNEXUS_TOKEN="<token>"
export CITYNEXUS_API_URL="https://<citynexus-pro-host>"
curl \
-H "Authorization: Bearer ${CITYNEXUS_TOKEN}" \
-H "Accept: application/json" \
"${CITYNEXUS_API_URL}/api/v1/citynexus/scenarios?city=copenhagen"
For requests with a JSON body, also send the Content-Type header:
curl \
-X POST \
-H "Authorization: Bearer ${CITYNEXUS_TOKEN}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"scenarioId":"<scenario-id>","mobility_model_input":{}}' \
"${CITYNEXUS_API_URL}/api/v1/citynexus/predictions?name=<prediction-name>"
Use the token in the API reference
The API reference is available in the api/index.html page. To make authenticated requests from that page:
Open the API reference page in a browser.
Click
Authorize.Paste the token value only, without the
Bearerprefix.Confirm the dialog, then use
Try it outon an endpoint.
Swagger UI adds the Authorization: Bearer <token> header automatically after authorization.