menu button

Optional calls

Get Transcript by Protocol & Page

Use this API to fetch transcript based on protocol slug and page. The response includes a list of all the textsegments for the given page.

Example: GraphQL Query & Fragments

export const GET_TRANSCRIPT_BY_PROTOCOL_AND_PAGE = `
fragment transcriptDetails on TranscriptSegment{
    text
    startTime
    endTime
}

fragment speakerDetails on ApiSpeakerType{
    slug
    givenName
    familyName
    preTitle
    postTitle
    gender
    party
    posLong
    posShort
    systemId
}

query GetTextsegmentsByProtocolAndPage($protocolSlug:String!, $page:Int!){
  getTextsegmentsByProtocolAndPage(protocolSlug:$protocolSlug, page:$page){
    textsegmentList{
      id
      speakerObj{
        ...speakerDetails
      }
      textJson{
        ...transcriptDetails
      }
      pos
    }
  }
}

Usage notes:

  • protocolSlug (required): Identifier of the protocol. Get this from the core API calls.
  • page (required): Get a defined page of the transcript. One page contains 30 textsegment objects.

JavaScript example

import axios from "axios";

async function getTranscriptByProtocolAndPage(protocolSlug, page) {
    const dataObj = {
        query: GET_TRANSCRIPT_BY_PROTOCOL_AND_PAGE,
        variables: { protocolSlug, page },
    };

    try {
        const response = await axios({
            method: "post",
            url: process.env.VUE_APP_GRAPHQL_API,
            data: JSON.stringify(dataObj),
            headers: {
                "Content-Type": "application/json",
                "x-api-key": process.env.VUE_APP_API_KEY,
            },
        });

        return response.data.data.getTextsegmentsByProtocolAndPage;
    } catch (error) {
        console.error(error);
        throw error;
    }
}

Have questions?

Still have questions? Talk to support.