NAV
shell

Using the API

Welcome to the Zod.TV - Transcoder API!

Making a GUEST Account

When you visit transcode.zod.tv you automatically get a guest account created with an offchain ZOD balance.

Your guest account works just as a regular account, there are no technical limitations.

Making a NEAR Account

You can create a NEAR Account at https://wallet.near.org

Make sure to backup your secret mnemonic phrase.

Authorization

Using the Authorization header

Authorization: Zod58 $OFFCHAIN_TOKEN

To authenticate offchain with ZOD you need to visit https://transcode.zod.tv/job_creator and scrolldown to fetch your offchain token.

Jobs

job_new_transcode

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/job_new_transcode -d @- << EOF
{
    "source": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
    "outputs": [
        {"target": "https://offchain.zod.tv/upload/05sqmfjchlllpqv3h9u2l0ag7k.mp4", "codec": "h264", "format": "mp4", "width": 720},
        {"target": "https://offchain.zod.tv/upload/05sqmfjchlllpqv3h9u2l0ag7l.mp4", "codec": "h264", "format": "mp4", "width": 480}
    ]
}
EOF
{
  "error":"ok",
  "uuid":"05srtdgnah4kmlleejfg56dbos"
}

Create a new job.

Request

Parameter Type Description
source String (Manditory) Source video file (s3://, https://, http://)
outputs List (Manditory) List of outputs

Note s3 protocol uses the S3 REST Authentication

S3 auth URL example for GCP is s3://${s3public}:${s3secret}@storage.googleapis.com/bucket/video.mp4

You need to create interoperability access key on GCP, https://console.cloud.google.com/storage/settings;tab=interoperability.

Every S3 provider has a different way to do this.

Output

Parameter Type Default Description
target String (Manditory) Upload location of output (s3://, https://, http://)
type String none Custom type (vrpreview_180, vrpreview_360)
codec String as_source [h264, hevc]
pixel_format String as_source Default gotten from source (https://gist.github.com/vans163/958cb4d7fb9adb9514c6ff956eb1f6df)
format String as_source Default gotten from source
width Integer as_source Can be "?" or -1 to auto scale
height Integer as_source Can be "?" or -1 to auto scale
offset TimeString 00:00:00.000 Must be format "00:00:00.000"
duration TimeString as_source Must be format "00:00:00.000"
bitrate Integer as_source Bitrate in bits per second
audio_codec String as_source Only "aac" is supported
audio_bitrate Integer as_source Audio Bitrate in bits per second

Extra Parameters (vrpreview_180, vrpreview_360)

Parameter Type Description
segments Integer (Manditory) Amount of segments to slice video into
segment_duration Integer (Manditory) Duration of each segment in seconds

Response

Name Type Description
error String The result of operation
uuid String The uuid of the created job

Error Codes

Error Description
no_source Source was not supplied
unsupported_source_protocol Source protocol is not supported (Join Discord for help)
no_outputs You did not specify any outputs
no_output_target One of your outputs did not have a target
unsupported_output_protocol Output protocol is not supported (Join Discord for help)
unsupported_type Custom job type is unsupported
unsupported_output_codec Output codec is invalid (must be h264 or hevc)
unsupported_output_format Output format is invalid
invalid_output_width Output width was invalid, it must be an integer or "?" or -1
invalid_output_height Output height was invalid, it must be an integer or "?" or -1
invalid_output_offset Output offset was invalid, it must be a timestring 00:00:00.000
invalid_output_duration Output duration was invalid, it must be a timestring 00:00:00.000
invalid_output_bitrate Output bitrate was not an integer
audio_codec_only_aac_supported Temporary error, audio is only AAC
unsupported_output_audio_codec Output audio codec is not supported
invalid_output_audio_bitrate Output audio bitrate was not an integer

job_verify_transcode

Same parameters as job_new_transcode, but does not submit the job, it only checks if the template is valid.

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/job_verify_transcode -d @- << EOF
{
    "source": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
    "outputs": [
        {"target": "https://offchain.zod.tv/upload/05sqmfjchlllpqv3h9u2l0ag7k.mp4", "codec": "h264", "format": "mp4", "width": 720},
        {"target": "https://offchain.zod.tv/upload/05sqmfjchlllpqv3h9u2l0ag7l.mp4", "codec": "h264", "format": "mp4", "width": 480}
    ]
}
EOF
{
  "error":"ok"
}

Response

Name Type Description
error String Can be ok or error

job_delete

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/job_delete -d @- << EOF
{
    "uuid": "05srtdgnah4kmlleejfg56dbos"
}
EOF
{
  "error":"ok"
}

Delete a new job and refunds any remaining stake (if applicable).

Jobs currently transcoding cannot be deleted.

Request

Parameter Type Description
uuid String Job id to delete

Response

Name Type Description
error String Can be ok or error

Error Codes

Error Description
invalid_job Job does not exist
job_in_progress Job is already running

job

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/job -d @- << EOF
{
    "uuid": "05srtdgnah4kmlleejfg56dbos"
}
EOF
{
  "error": "ok",
  "job": {...}
}

Get job by uuid.

Response

Name Type Description
error String Can be ok or error
job String Job details

Account Onchain

This API is to manage your account and ZOD tokens on NEAR.

ZOD follows the NEP-141 standard. ZOD token balances are denominated to the yocto (exponent 24).

These examples may use the near-cli (https://github.com/near/near-cli) to make calls.

npm install -g near-cli

mint

$ACCOUNT=myself.near
NEAR_ENV=mainnet near call --amount 100.1 zodtv.near mint '{"expected_tokens": "100"}' --accountId $ACCOUNT --gas 300000000000000
"103333999999999999999999998199"

This function attaches 100.1 NEAR to mint ZOD, with slippage set to get at least 100 ZOD tokens. This function call fails if the amount of ZOD tokens allocated will be less than the expected_tokens and the attached NEAR is refunded.

ZOD is minted based on the current price of NEAR and the total minted, the more minted ZOD there is the less every future mint provides. More details on https://transcode.zod.tv/network.

Response

The ZOD tokens minted.

mint_status


node << EOF
const fetch = require('node-fetch');
async function go() {
  const args_base64 = Buffer.from('{}').toString('base64')
  const params = {account_id: "zodtv.near", method_name: "mint_status", 
    request_type: "call_function", finality: "final", "args_base64": args_base64}
  const json_args = {jsonrpc: "2.0", id: "1", method: "query", params: params}

  const fetch_args = {
    method: "POST",
    body: JSON.stringify(json_args),
    headers: {
      "Content-Type": "application/json"
    }
  }
  const response = await fetch("https://rpc.mainnet.near.org", fetch_args);
  const {result} = await response.json();

  const mint_status = JSON.parse((new TextDecoder()).decode(new Uint8Array(result.result)))
  console.log(mint_status)
}
go()
EOF
{
  "total_minted": "3120000000000000000000000000",
  "level": "0",
  "near_price": "6000000000000000000000000",
  "zod_price": "10000000000000000000000"
}

This function returns the current status of the ZOD mint contract.

This example shows how to use the NEAR MAINNET RPC api to query contract state instead of near-cli.

Response

Name Type Description
total_minted u128 Total ZOD minted from contract
level u128 Distribution level
near_price u128 Current price of near that the contract has
zod_price u128 Current price of ZOD from minting

ft_balance_of

$ACCOUNT=myself.near
NEAR_ENV=mainnet near view --accountId $ACCOUNT zod.near ft_balance_of '{"account_id": "'$ACCOUNT'"}'

"8332999999999999999999998199"

Check the ZOD token balance of any account.

Response

ZOD token balance.

Account Offchain

This API is to manage your account offchain.

balance

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/balance -d @- << EOF
{}
EOF
{
  "error": "ok",
  "bonus": "1000000000000000000000000",
  "balance": "3200000000000000000000000",
  "spent": "200000000000000000000000",
}

Your offchain balances.

Response

Name Type Description
error String Can be ok or error
bonus String Your bonus balance (guest accounts / promotions), this balance cannot be sent onchain.
balance String Your total balance locked onchain.
spent String Your total balance spent.

sync_balance

curl -H "Content-Type: application/json" \
-H "Authorization: Zod58 LAB6MFqa2M2H5FTif8Zuo1Y8EortVGpNfyQuyoET9Ea9QQLgADQJWFNZr1CSuMSkskE4s5TMVzRK6wcCwU92AaMT9maZGwvvArwtBReb6sFoVk4fEub9CGTNnRpZsTqT9RVFoRcvURg2H96T7iCdapxxjTQzZCdUjRswG5nf65PAjapZHPbuPADdD9XmvHkgJXRUVzzWWiw8E6DyiVyJGdNkWDCZLBuB95RzrDyg1r9c5s4meJsR7RDDmXtmA9TmSMGgmFiJt7RuGMJYW7ckEgutn2AP35htqKNBgj59JMYPUpisqn" \
-X POST https://offchain.zod.tv/sync_balance -d @- << EOF
{}
EOF
{
  "error": "ok",
  "bonus": "1000000000000000000000000",
  "balance": "3200000000000000000000000",
  "spent": "200000000000000000000000",
}

Sync your onchain balance forcefully if its out of sync for some reason.

Response is same to balance endpoint.