The Cards endpoint allows you to retrieve cards from your Storyteller tenant. Cards are interactive content elements that can contain various types of media and information.
You can page this endpoint using either currentPage + pageSize or legacy-style skipCount + maxResultCount.
In legacy mode, omitted aliases fall back to skipCount=0 and maxResultCount=10. Because integrations responses still return currentPage, skipCount must land on a page boundary for the effective page size.
constfetch=require('node-fetch');asyncfunctiongetCards(searchText='',externalId='',currentPage=1,pageSize=10,sort=''){constparams=newURLSearchParams({...(searchText&&{searchText}),...(externalId&&{externalId}),currentPage:currentPage.toString(),pageSize:pageSize.toString(),...(sort&&{sort})});try{constresponse=awaitfetch(`https://integrations.usestoryteller.com/api/cards?${params}`,{method:'GET',headers:{'x-storyteller-api-key':process.env.STORYTELLER_API_KEY}});if(!response.ok){consterrorData=awaitresponse.json();thrownewError(`HTTP ${response.status}: ${errorData.detail}`);}constdata=awaitresponse.json();returndata;}catch(error){console.error('Error fetching cards:',error);throwerror;}}// Usage examplesasyncfunctionexamples(){// Get all cardsconstallCards=awaitgetCards();console.log(`Found ${allCards.cards.length} cards`);// Search for specific cardsconstsearchResults=awaitgetCards('product','',1,20);console.log(`Found ${searchResults.cards.length} cards matching "product"`);// Filter by external IDconstfilteredCards=awaitgetCards('','product-card-001',1,20);console.log(`Found ${filteredCards.cards.length} cards with external ID "product-card-001"`);// Get cards sorted by publish dateconstsortedCards=awaitgetCards('','',1,50,'PublishedDesc');console.log(`Retrieved ${sortedCards.cards.length} cards sorted by publish date`);// Get card IDs and typesconstcardInfo=allCards.cards.map(card=>({id:card.id,type:card.cardType,title:card.title}));console.log('Available cards:',cardInfo);}
importrequestsimportosfromurllib.parseimporturlencodedefget_cards(search_text='',external_id='',current_page=1,page_size=10,sort=''):url='https://integrations.usestoryteller.com/api/cards'headers={'x-storyteller-api-key':os.environ.get('STORYTELLER_API_KEY')}params={'currentPage':current_page,'pageSize':page_size}ifsearch_text:params['searchText']=search_textifexternal_id:params['externalId']=external_idifsort:params['sort']=sorttry:response=requests.get(url,headers=headers,params=params)response.raise_for_status()data=response.json()returndataexceptrequests.exceptions.RequestExceptionase:print(f'Error fetching cards: {e}')ifhasattr(e.response,'json'):print(f'Error details: {e.response.json()}')raise# Usage examplestry:# Get all cardsall_cards=get_cards()print(f'Found {len(all_cards["cards"])} cards')# Search for specific cardssearch_results=get_cards(search_text='product',page_size=20)print(f'Found {len(search_results["cards"])} cards matching "product"')# Filter by external IDfiltered_cards=get_cards(external_id='product-card-001',page_size=20)print(f'Found {len(filtered_cards["cards"])} cards with external ID "product-card-001"')# Get cards sorted by publish datesorted_cards=get_cards(page_size=50,sort='PublishedDesc')print(f'Retrieved {len(sorted_cards["cards"])} cards sorted by publish date')# Extract card informationcard_info=[{'id':card['id'],'type':card['cardType'],'title':card['title']}forcardinall_cards['cards']]print('Available cards:',card_info)exceptExceptionase:print(f'Failed to fetch cards: {e}')
usingSystem;usingSystem.Net.Http;usingSystem.Threading.Tasks;usingSystem.Collections.Generic;usingNewtonsoft.Json;publicclassCardsClient{privatereadonlyHttpClient_httpClient;privatereadonlystring_baseUrl="https://integrations.usestoryteller.com";publicCardsClient(stringapiKey){_httpClient=newHttpClient();_httpClient.DefaultRequestHeaders.Add("x-storyteller-api-key",apiKey);}publicasyncTask<CardsResponse>GetCardsAsync(stringsearchText="",stringexternalId="",intcurrentPage=1,intpageSize=10,stringsort=""){try{varqueryParams=newList<string>{$"currentPage={currentPage}",$"pageSize={pageSize}"};if(!string.IsNullOrEmpty(searchText)){queryParams.Add($"searchText={Uri.EscapeDataString(searchText)}");}if(!string.IsNullOrEmpty(externalId)){queryParams.Add($"externalId={Uri.EscapeDataString(externalId)}");}if(!string.IsNullOrEmpty(sort)){queryParams.Add($"sort={sort}");}varqueryString=string.Join("&",queryParams);varresponse=await_httpClient.GetAsync($"{_baseUrl}/api/cards?{queryString}");response.EnsureSuccessStatusCode();varresponseContent=awaitresponse.Content.ReadAsStringAsync();varcards=JsonConvert.DeserializeObject<CardsResponse>(responseContent);returncards;}catch(HttpRequestExceptionex){thrownewException($"Error fetching cards: {ex.Message}",ex);}}}publicclassCardsResponse{publicCard[]Cards{get;set;}publicintPageSize{get;set;}publicintCurrentPage{get;set;}publicintTotalPages{get;set;}}publicclassCard{publicGuidId{get;set;}publicstringInternalTitle{get;set;}publicstringTitle{get;set;}publicstringSubtitle{get;set;}publicstringExternalId{get;set;}publicstringCardType{get;set;}publicintDuration{get;set;}publicDateTimeCreatedAt{get;set;}publicDateTimePublishedAt{get;set;}publicstringCmsUrl{get;set;}publicstringCmsAnalyticsUrl{get;set;}publicCategory[]Categories{get;set;}publicCollection[]Collections{get;set;}}publicclassCategory{publicstringTitle{get;set;}publicstringExternalId{get;set;}}publicclassCollection{publicstringId{get;set;}publicstringTitle{get;set;}publicstringExternalId{get;set;}}// Usagevarclient=newCardsClient(Environment.GetEnvironmentVariable("STORYTELLER_API_KEY"));try{// Get all cardsvarallCards=awaitclient.GetCardsAsync();Console.WriteLine($"Found {allCards.Cards.Length} cards");// Search for specific cardsvarsearchResults=awaitclient.GetCardsAsync("product","",1,20);Console.WriteLine($"Found {searchResults.Cards.Length} cards matching 'product'");// Filter by external IDvarfilteredCards=awaitclient.GetCardsAsync("","product-card-001",1,20);Console.WriteLine($"Found {filteredCards.Cards.Length} cards with external ID 'product-card-001'");// Get cards sorted by publish datevarsortedCards=awaitclient.GetCardsAsync("","",1,50,"PublishedDesc");Console.WriteLine($"Retrieved {sortedCards.Cards.Length} cards sorted by publish date");// Extract card informationvarcardInfo=allCards.Cards.Select(c=>new{Id=c.Id,Type=c.CardType,Title=c.Title}).ToArray();Console.WriteLine($"Available cards: {string.Join(",", cardInfo.Select(c => $"{c.Title}({c.Type})"))}");}catch(Exceptionex){Console.WriteLine($"Error: {ex.Message}");}
# Get all cards (first page)curl-XGET"https://integrations.usestoryteller.com/api/cards"\-H"x-storyteller-api-key: your-api-key-here"# Search for specific cardscurl-XGET"https://integrations.usestoryteller.com/api/cards?searchText=product&pageSize=20"\-H"x-storyteller-api-key: your-api-key-here"# Filter by external IDcurl-XGET"https://integrations.usestoryteller.com/api/cards?externalId=product-card-001"\-H"x-storyteller-api-key: your-api-key-here"# Get cards sorted by publish datecurl-XGET"https://integrations.usestoryteller.com/api/cards?sort=PublishedDesc&pageSize=50"\-H"x-storyteller-api-key: your-api-key-here"
Cards can be referenced in workflow metadata when creating related content:
// 1. Get available cardsconstcardsData=awaitgetCards();constproductCards=cardsData.cards.filter(card=>card.cardType==='product');// 2. Use card ID in workflow metadataconstworkflowMetadata={'https://example.com/video.mp4':{'Title':'Product Demo Video','relatedCardId':productCards[0].id,// Reference related card'cardType':productCards[0].cardType}};// 3. Execute workflow with card metadataawaitexecuteWorkflow(['create-product-story'],['https://example.com/video.mp4'],workflowMetadata);
asyncfunctiongetCardsByType(cardType){constallCards=awaitgetAllCards();returnallCards.filter(card=>card.cardType===cardType);}// Get specific card typesconstproductCards=awaitgetCardsByType('product');constvideoCards=awaitgetCardsByType('video');constinfoCards=awaitgetCardsByType('info');
asyncfunctiongetAllCards(){letallCards=[];letcurrentPage=1;lettotalPages=1;do{constresponse=awaitgetCards('',currentPage,50);allCards.push(...response.cards);totalPages=response.totalPages;currentPage++;}while(currentPage<=totalPages);returnallCards;}// UsageconstallCards=awaitgetAllCards();console.log(`Retrieved ${allCards.length} total cards`);
{"status":401,"type":"https://datatracker.ietf.org/doc/html/rfc7235#section-3.1","title":"Unauthorized","detail":"No valid API key provided","instance":""}
{"status":400,"type":"https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1","title":"Bad Request","detail":"Invalid page size. Must be between 1 and 100","instance":""}