Comment on page

Example Implementation

Disclaimer

The Postman desktop app currently crashes on responses with a binary in the body (see this issue). We recommend to use the web app or our curl examples for testing.

Test Podcast

We have created a test podcast, "The OCPS Show", for testing and prototyping purposes that contains one episode. This episode's audio file behaves adherent to the OCPS.
Test Podcast
Name: "The OCPS Show"
Episode Length: 03:30 / 10:54 (free / full)
Episode GUID: a3a1b651-94e2-56f0-9dee-a23813aa7220

Test episode behavior

  • The first 03:30 minutes of the episode are available for free
  • Download request:
    • No LSAT support: 03:30 minutes are downloaded
    • LSAT support: server responds with status 402 "payment required" and the necessary payment information
  • Streaming request:
    • No LSAT support: client can stream 03:30 minutes, then the episode is "finished"
    • LSAT support: client can stream 03:30 minutes, then the the server responds with 402 "payment required" and the necessary payment information

Interacting with the test episode

Query file information

head
{episode audio url}
Retrieve file meta data

Make a valid keysend payment

For testing purposes, it is sufficient to pay the recipient returned in the 402 response. The SATS you send during testing go to our node, we'll happily return them to you if you contact us.
Make sure the keysend payment contains the following data in the custom records:
{
"episode_guid": "a3a1b651-94e2-56f0-9dee-a23813aa7220", //required
"token": "AAAA", //recommended
"action": "lsat" // recommended
}
If you can't or don't want to make the keysend payment, you can use this preimage for testing:
3630626264383464316435666130356136653430616139386337663331643365

Download the episode audio

Client with no LSAT support:
get
{episode audio url}
Download request (no LSAT)
Client with LSAT support:
get
{episode audio url}
Download request before payment
get
{episode audio url}
Download request after payment

Stream the episode audio

Client with no LSAT support:
get
{episode audio url}
Stream request (no LSAT)
Client with LSAT support:
get
{episode audio url}
Stream request before payment
get
{episode audio url}
Stream request after payment

Full interaction examples (Shell / Curl)

No LSAT support
LSAT via headers
LSAT via query parameters
#!/bin/sh
# head request to retrieve metadata
echo "> file metadata:"
curl -I https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3
# range (stream) request for a part of the free content
echo "\n> this request will download the first part of the freely available content (lsat-test-free-first-part.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "range: bytes=0-2500000" --output lsat-test-free-first-part.mp3
# download request for the full free resource
echo "\n> this request will download the freely available content (lsat-test-free.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 --output lsat-test-free.mp3
#!/bin/sh
# head request to retrieve metadata
echo "> file metadata:"
curl -I https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "X-Accept-Authenticate: lsat-keysend"
# range (stream) request for free range
echo "\n> this request will download the freely available content (lsat-test-free.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "X-Accept-Authenticate: lsat-keysend" -H "range: bytes=0-5000000" --output lsat-test-free.mp3
# range (stream) request for protected range without payment
echo "\n> this request will fail with 402 because it requests protected content with an X-Accept-Authenticate header:"
curl -I -X GET https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "X-Accept-Authenticate: lsat-keysend" -H "range: bytes=0-10000000"
# range (stream) request for protected range with payment
echo "\n> this request will download a part of the protected content using a valid preimage (lsat-test-more-than-free.mp3):"
curl -I -X GET https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "AUTHORIZATION: LSAT AAAA:3630626264383464316435666130356136653430616139386337663331643365" -H "range: bytes=0-10000000" --output lsat-test-more-than-free.mp3
# download request with payment
echo "\n> this request will download the full resource using a valid preimage (lsat-test-full.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3 -H "AUTHORIZATION: LSAT AAAA:3630626264383464316435666130356136653430616139386337663331643365" --output lsat-test-full.mp3
#!/bin/sh
# head request to retrieve metadata
echo "> file metadata:"
curl -I https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3
# range (stream) request for free range
echo "\n> this request will download the freely available content (lsat-test-free.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3?lsat-accept-authenticate=lsat-keysend -H "range: bytes=0-5000000" --output lsat-test-free.mp3
# range (stream) request for protected range without payment
echo "\n> this request will fail with 402 because it requests protected content with an lsat-accept-authenticate query parameter:"
curl -I -X GET https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3?lsat-accept-authenticate=lsat-keysend -H "range: bytes=0-1000000"
# range (stream) request for protected range with payment
echo "\n> this request will download a part of the protected content using a valid preimage (lsat-test-more-than-free.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3?lsat-authorization=AAAA%3A3630626264383464316435666130356136653430616139386337663331643365 -H "range: bytes=0-10000000" --output lsat-test-more-than-free.mp3
# download request with payment
echo "\n> this request will download the full resource using a valid preimage (lsat-test-full.mp3):"
curl https://lsat-test.conshax.app/podcast/a3a1b651-94e2-56f0-9dee-a23813aa7220/episode/lsat-test.mp3?lsat-authorization=AAAA%3A3630626264383464316435666130356136653430616139386337663331643365 --output lsat-test-full.mp3