3Speak - Creator Studio - APIs explained along with example usage

avatar
(Edited)

▶️ Watch on 3Speak


Hello Community Members,

This is an unofficial update from @sagarkothari88 about 3Speak.
Official updates will be provided by @threespeak 's handle.

thumbnail

Supporting PostingKey based user sessions

Step 1 - Add Necessary dependencies

import React, { useState } from "react";

import axios from "axios";
import { wrapper } from "axios-cookiejar-support";
import { CookieJar } from "tough-cookie";

import hive from "@hiveio/hive-js";

axios.defaults.headers.post["Access-Control-Allow-Origin"] = "*";
const jar = new CookieJar();
const client = wrapper(axios.create({ jar }));

const studioEndPoint = "https://studio.3speak.tv";

Step 2 - Get Encoded JWT Access Token

  • In the following logMe() function, you can see that, I've just logged the decrypted access-token.
async function logMe() {
try {
  let response = await client.get(
    `${studioEndPoint}/mobile/login?username=${username}`,
    {
      withCredentials: false,
      headers: {
        "Content-Type": "application/json",
      },
    }
  );
  console.log(`Response: ${JSON.stringify(response)}`);
  const memo = response.data.memo;
  console.log(`Memo - ${response.data.memo}`);
  let access_token = hive.memo.decode(postingKey, memo);
  access_token = access_token.replace("#", "");
  console.log(`Decrypted ${access_token}\n\n`);
} catch (err) {
  console.log(err);
  throw err;
}
}

Step 3 - Get All Videos

async function getAllVideoStatuses(access_token) {
try {
  let response = await client.get(
    `${studioEndPoint}/mobile/api/my-videos`,
    {
      withCredentials: false,
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${access_token}`
      },
    }
  );
  return response.data;
} catch (err) {
  console.log(err);
  throw err;
}
}

That's it.

  • Yes. It is as simple as this.
  • Get JWT Token, Decrypt it & use it to get videos of a user.

What are you waiting for?

  • You can go ahead & implement it in your DApp

Important Notes

  • 3Speak is also working on a complete re-write backend.
  • In future, we may have different APIs
  • These APIs may get deprected in near future.

Feedback / Info

  • Do you want more Info? Please let me know via comment section.
  • Do you have feedback to share? Please use comment section

Support Me

Please 🙏Support Me
Donate Hive Or HBD Vote me as Hive Witness

Other Communities

I recommend joining these communities on Hive & Discord.


Click on the banner to join


Click on the banner to join



Important 3Speak Links

3Speak.tv3Speak Twitter3Speak Hive3Speak Telegram
3Speak in SpanishDownload Android AppDownload iOS AppDownload Desktop App
Join 3Speak DiscordSetup Encoder NodeVote for 3Speak ProposalVote 3Speak as Witness

Cheers
Have a good one


▶️ 3Speak



0
0
0.000
5 comments
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited..

This post received an extra 5.01% vote for delegating HP / holding IUC tokens.

0
0
0.000
avatar

Congratulations @sagarkothari88! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You distributed more than 24000 upvotes.
Your next target is to reach 25000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

LEO Power Up Day - March 15, 2023
HiveBuzz rewards participants in the Afri-Tunes Anniversary event
The Hive Gamification Proposal
0
0
0.000