Code Examples
Example code for common tasks
Code Examples
Ready-to-use code snippets for common StweetHQ integration tasks across multiple languages and frameworks.
Overview
This page collects practical examples to help you get up and running quickly. Each example is self-contained and can be copied directly into your project. Examples cover authentication, fetching testimonials, handling webhooks, and rendering widgets in popular frameworks.
Fetching Testimonials
Use the SDK or a direct API call to retrieve testimonials filtered by tag, collection, or rating. The response includes all testimonial fields along with pagination metadata. Pass query parameters like tag, limit, and sort to customize the results for your use case.
Handling Webhooks
Set up an HTTP endpoint in your server framework of choice to receive webhook payloads. Verify the signature header against your webhook secret, parse the event type, and route to the appropriate handler. Examples are provided for Express, FastAPI, and Go’s net/http.
Custom Widget Rendering
Build a testimonial carousel or grid using the headless SDK and your preferred frontend framework. Fetch the data on mount, store it in local state, and render each testimonial with your own card component. Examples are provided for React, Vue, and Svelte with full TypeScript support.
Next Steps
Explore the full API reference for advanced query options, or visit the SDKs page to find the client library for your language.