You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blockfrost-openapi.yaml
+6-353Lines changed: 6 additions & 353 deletions
Original file line number
Diff line number
Diff line change
@@ -232,365 +232,18 @@ info:
232
232
## Midnight API
233
233
234
234
235
-
The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data—blocks, transactions, contracts, and wallet-related events—indexed from the Midnight blockchain.
236
-
237
-
The deployed version of the Midnight Indexer API is **v4**.
238
-
239
-
[](./midnight/)
240
-
241
-
For the raw GraphQL schema specification, see the [Midnight Indexer GraphQL Schema](midnight/midnight-indexer-api.graphql).
242
-
243
-
### Quick Start
244
-
245
-
Create a Midnight project on [blockfrost.io](https://blockfrost.io) and make your first API call:
246
-
247
-
```bash
248
-
curl -X POST https://midnight-mainnet.blockfrost.io/api/v0 \
Blockfrost exposes Midnight Indexer API and Midnight Node RPC endpoints:
235
+
The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data — blocks, transactions, contracts, and wallet-related events — indexed from the Midnight blockchain.
The **Node RPC** endpoint exposes direct connection to the Midnight Node RPC for low-level runtime access, wallet providers, and transaction submission — use it with libraries like [midnight.js](https://github.com/midnightntwrk/midnight-js) that need a node connection.
279
-
280
-
### Request Format
281
-
282
-
Send a POST request with a JSON body containing:
283
-
* `query` (required): The GraphQL query, mutation, or subscription string
284
-
* `variables` (optional): Variables for the GraphQL operation
When using WebSocket in the browser (which doesn't support custom headers), include your project ID as a subprotocol by prefixing it with `project_id_`:
354
-
```javascript
355
-
new WebSocket("wss://midnight-mainnet.blockfrost.io/api/v0/ws", [
356
-
"graphql-transport-ws",
357
-
"project_id_YOUR_PROJECT_ID"
358
-
]);
359
-
```
360
-
361
-
### HTTP Query Examples
362
-
363
-
**Query the latest block:**
364
-
```bash
365
-
curl -X POST https://midnight-mainnet.blockfrost.io/api/v0 \
Subscriptions use a WebSocket connection following the GraphQL over WebSocket protocol.
406
243
407
-
Most subscriptions accept an optional `offset` parameter, allowing you to resume from a specific block height or transaction hash instead of starting from the tip. This is useful for catching up after a reconnect without re-processing events you've already seen.
244
+
For the full documentation — queries, mutations, subscriptions, authentication options, and examples — see the Midnight GraphQL API Reference:
**ContractActionOffset** (oneOf — provide exactly one):
518
-
* `blockOffset`: A BlockOffset
519
-
* `transactionOffset`: A TransactionOffset
520
-
521
-
If no offset is provided, the latest result is returned.
522
-
523
-
### Shielded Transactions
524
-
525
-
Shielded transactions are at the core of Midnight's privacy model. Because transaction data is encrypted on-chain, the indexer needs a **viewing key** to determine which transactions are relevant to a specific wallet.
526
-
527
-
The `connect` mutation establishes a server-side session for a given viewing key. The indexer uses this key to scan the chain and filter shielded transactions relevant to that wallet. It returns a **session ID** used to authenticate the `shieldedTransactions` subscription.
528
-
529
-
When you no longer need to monitor shielded transactions for a wallet, call the `disconnect` mutation with the session ID to end the session and free server-side resources.
530
-
531
-
**Step 1 — Connect with a viewing key:**
532
-
```bash
533
-
curl -X POST https://midnight-mainnet.blockfrost.io/api/v0 \
The viewing key can be in Bech32m format (preferred, e.g. `mn_shield-esk1...`) or hex.
549
-
550
-
**Step 2 — Subscribe to shielded transactions:**
551
-
552
-
Using the session ID from the `connect` mutation, subscribe via WebSocket:
553
-
```json
554
-
{
555
-
"id": "1",
556
-
"type": "subscribe",
557
-
"payload": {
558
-
"query": "subscription($sid: HexEncoded!) { shieldedTransactions(sessionId: $sid, sendProgressUpdates: true) { ... on ViewingUpdate { index update { ... on RelevantTransaction { transaction { hash } } } } ... on ShieldedTransactionsProgress { highestIndex highestRelevantIndex highestRelevantWalletIndex } } }",
559
-
"variables": { "sid": "SESSION_ID_HEX" }
560
-
}
561
-
}
562
-
```
563
-
564
-
The subscription emits two event types:
565
-
* `ViewingUpdate` — contains relevant transactions and Merkle tree updates for the wallet
566
-
* `ShieldedTransactionsProgress` — reports sync progress (`highestIndex`, `highestRelevantIndex`, `highestRelevantWalletIndex`), useful for showing progress in a UI. Controlled by the `sendProgressUpdates` parameter (default: `true`).
567
-
568
-
**Step 3 — Disconnect when done:**
569
-
```bash
570
-
curl -X POST https://midnight-mainnet.blockfrost.io/api/v0 \
0 commit comments