Stream API #7

Open
opened 2023-06-27 14:17:44 +00:00 by Kieran · 9 comments
Owner

All endpoints use NIP-98 Auth.

Streaming providers publish all nostr stream events (30_311 event kind).

This means that users simply need to start streaming for the nostr event to be marked as "live", and likewise the stream should be marked as offline when the stream is down.

Streaming providers MUST include the p tag for the host as per NIP-102, the user who is p tagged should provide a sig of the a tag used in their event to prevent fake "host" tagged events.

This sig can be sent to PATCH /account by taking the a tag from GET /account and hashing it with SHA256 and signing the hash with their private key.

Account Info

GET /account - Login/Register/Account Info
Response:

{
    "endpoints": [
        {
            "name": "Premium",
            "url": "rtmps://live.stream/live",
            "key": "aaaaaaaaaa",
            "capabilities": [
                "variant:source",
                "variant:720h:3000",
                "variant:480h:1500",
                "variant:240h:800",
                "variant:120h:400",
                "output:hls",
                "output:webrtc",
                "output:rtmp",
                "dvr:720h"
            ],
            "cost": {
                "unit": "min",
                "rate": 21
            }
        },
        {
            "name": "Lite",
            "url": "rtmps://live.stream/live",
            "key": "aaaaaaaaaa",
            "capabilities": [
                "variant:source",
                "output:hls"
            ],
            "cost": {
                "unit": "min",
                "rate": 2.1
            }
        }
    ],
    "event": {}, // same as PATCH /event payload, contains current stream details
    "a": "30311:<host_pubkey>:<stream_id>",
    "balance": 10000,
    "tos": {
        "accepted": false,
        "link": "https://example.com/tos.html"
    }
}

Update Account

PATCH /account - Update account
Request:

{
  "accept_tos": true,
  "a_sig":  "<schnorr_sig of sha256('a') from /account>"
}

Response: 200

Topup

GET /topup?amount=number - Get invoice to top up account in sats
Response:

{
  "pr": "lnbc1xxx"
}

Update Event

PATCH /event - Update stream event
Request:

{
    "title": "example",
    "summary": "example",
    "tags": [
        "nostr",
        "example",
        "memes"
    ],
    "image": "https://image.com/meme.jpg",
    "starts": 1689448388,
    "content_warning": "nsfw",
    "guests": [
        {
            "pubkey": "aaa",
            "relay": "wss://relay1.com",
            "role": "Co-Host",
            "zap_split": 1
        },
        {
            "pubkey": "bbb",
            "relay": "wss://relay2.com",
            "role": "Producer",
            "zap_split": 1
        },
        {
            "pubkey": "ccc",
            "relay": "wss://relay3.com",
            "role": "Lurker",
            "zap_split": 0
        }
    ]
}

Response:

{
  "event": {nostr event}
}
All endpoints use NIP-98 Auth. Streaming providers publish all nostr stream events (30_311 event kind). This means that users simply need to start streaming for the nostr event to be marked as `"live"`, and likewise the stream should be marked as offline when the stream is down. Streaming providers MUST include the `p` tag for the host as per NIP-102, the user who is `p` tagged should provide a sig of the `a` tag used in their event to prevent fake "host" tagged events. This sig can be sent to `PATCH /account` by taking the `a` tag from `GET /account` and hashing it with SHA256 and signing the hash with their private key. ### Account Info `GET /account` - Login/Register/Account Info Response: ```json { "endpoints": [ { "name": "Premium", "url": "rtmps://live.stream/live", "key": "aaaaaaaaaa", "capabilities": [ "variant:source", "variant:720h:3000", "variant:480h:1500", "variant:240h:800", "variant:120h:400", "output:hls", "output:webrtc", "output:rtmp", "dvr:720h" ], "cost": { "unit": "min", "rate": 21 } }, { "name": "Lite", "url": "rtmps://live.stream/live", "key": "aaaaaaaaaa", "capabilities": [ "variant:source", "output:hls" ], "cost": { "unit": "min", "rate": 2.1 } } ], "event": {}, // same as PATCH /event payload, contains current stream details "a": "30311:<host_pubkey>:<stream_id>", "balance": 10000, "tos": { "accepted": false, "link": "https://example.com/tos.html" } } ``` ### Update Account `PATCH /account` - Update account Request: ```json { "accept_tos": true, "a_sig": "<schnorr_sig of sha256('a') from /account>" } ``` Response: 200 ### Topup `GET /topup?amount=number` - Get invoice to top up account in sats Response: ```json { "pr": "lnbc1xxx" } ``` ### Update Event `PATCH /event` - Update stream event Request: ```json { "title": "example", "summary": "example", "tags": [ "nostr", "example", "memes" ], "image": "https://image.com/meme.jpg", "starts": 1689448388, "content_warning": "nsfw", "guests": [ { "pubkey": "aaa", "relay": "wss://relay1.com", "role": "Co-Host", "zap_split": 1 }, { "pubkey": "bbb", "relay": "wss://relay2.com", "role": "Producer", "zap_split": 1 }, { "pubkey": "ccc", "relay": "wss://relay3.com", "role": "Lurker", "zap_split": 0 } ] } ``` Response: ```json { "event": {nostr event} } ```
Kieran self-assigned this 2023-06-30 13:09:17 +00:00
Kieran added the
enhancement
label 2023-07-07 13:31:24 +00:00
Author
Owner

Added TOS to /account

Added TOS to `/account`
Author
Owner

Added note about signed a tag

Added note about signed `a` tag
Author
Owner

Add endpoints to account to accommodate multiple cost plans

Add `endpoints` to account to accommodate multiple cost plans
Author
Owner

Added guests to patch event

Added `guests` to patch event
Author
Owner

Added bitrate to variant

Added bitrate to variant
Author
Owner
zap.stream solution: https://miro.com/app/board/uXjVMzHeLT4=/?share_link_id=336961681393
Author
Owner

Added note about event using PATCH /event payload for stream details

Added note about `event` using `PATCH /event` payload for stream details
Author
Owner

Added dvr capability, format is dvr:<resolution> resolution format is the same as variant capability tag.

eg. dvr:source / dvr:480h

Added `dvr` capability, format is `dvr:<resolution>` resolution format is the same as `variant` capability tag. eg. `dvr:source` / `dvr:480h`
Collaborator

Should we allow to specify a goal a for streams to be able to link streams to goals and not the other way around? This would allow streamers to configure goals that show up on every stream.

Should we allow to specify a goal `a` for streams to be able to link streams to goals and not the other way around? This would allow streamers to configure goals that show up on every stream.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Kieran/zap.stream#7
No description provided.