# AI Studios - Owner/Co-Creator Metrics Dashboard POST /api/v1/aistudios/metrics/ Content-Type: application/json **OWNER OR CO-CREATOR ACCESS:** Metrics dashboard for publication owners and co-creators. Provides detailed analytics including: - Publication basic information (created_at, allow_bookings) - Experience counts by type (AI_EXPERT, AI_NOTE, QUEST, PODCAST) - Engagement metrics (views, likes, bookmarks, shares, comments) - Monthly active users count - Appointments count (placeholder - TODO) - Social metrics (followers and following counts for publication owner) **Access Control:** Restricted to publication owners or co-creators only. **Caching:** Response cached for 1 hour using Django's cache framework. **Performance:** Optimized queries with select_related and prefetch_related. Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/ai-studios-metrics-owner-co-creator/aistudios-metrics-create ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v1/aistudios/metrics/: post: operationId: aistudios-metrics-create summary: AI Studios - Owner/Co-Creator Metrics Dashboard description: >- **OWNER OR CO-CREATOR ACCESS:** Metrics dashboard for publication owners and co-creators. Provides detailed analytics including: - Publication basic information (created_at, allow_bookings) - Experience counts by type (AI_EXPERT, AI_NOTE, QUEST, PODCAST) - Engagement metrics (views, likes, bookmarks, shares, comments) - Monthly active users count - Appointments count (placeholder - TODO) - Social metrics (followers and following counts for publication owner) **Access Control:** Restricted to publication owners or co-creators only. **Caching:** Response cached for 1 hour using Django's cache framework. **Performance:** Optimized queries with select_related and prefetch_related. tags: - subpackage_aiStudiosMetricsOwnerCoCreator responses: '200': description: Owner/Co-creator metrics retrieved successfully content: application/json: schema: $ref: '#/components/schemas/AIStudiosOwnerMetrics' '403': description: Forbidden - Owner or co-creator access required content: application/json: schema: description: Any type '404': description: Publication not found content: application/json: schema: description: Any type requestBody: content: application/json: schema: type: object properties: url: type: string description: Publication custom URL (owner or co-creator access required) required: - url components: schemas: PublicationInfo: type: object properties: id: type: integer name: type: string custom_url: type: string created_at: type: string format: date-time allow_bookings: type: boolean required: - id - name - custom_url - created_at - allow_bookings title: PublicationInfo ExperienceCounts: type: object properties: AI_EXPERT: type: integer AI_NOTE: type: integer QUEST: type: integer PODCAST: type: integer total: type: integer required: - AI_EXPERT - AI_NOTE - QUEST - PODCAST - total title: ExperienceCounts EngagementMetrics: type: object properties: total_views: type: integer total_likes: type: integer total_bookmarks: type: integer total_shares: type: integer total_comments: type: integer total_appointments: type: integer description: 'TODO: Implement appointments integration' monthly_active_users: type: integer required: - total_views - total_likes - total_bookmarks - total_shares - total_comments - total_appointments - monthly_active_users title: EngagementMetrics SocialMetrics: type: object properties: followers_count: type: integer following_count: type: integer required: - followers_count - following_count title: SocialMetrics AIStudiosOwnerMetrics: type: object properties: publication: $ref: '#/components/schemas/PublicationInfo' experience_counts: $ref: '#/components/schemas/ExperienceCounts' metrics: $ref: '#/components/schemas/EngagementMetrics' social_metrics: $ref: '#/components/schemas/SocialMetrics' generated_at: type: string format: date-time required: - publication - experience_counts - metrics - social_metrics - generated_at description: |- Serializer for AI Studio owner metrics dashboard. Returns comprehensive analytics data for publication owners. title: AIStudiosOwnerMetrics ``` ## SDK Code Examples ```python Example owner metrics response import requests url = "https://api.example.com/api/v1/aistudios/metrics/" headers = {"Content-Type": "application/json"} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Example owner metrics response const url = 'https://api.example.com/api/v1/aistudios/metrics/'; const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: undefined}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Example owner metrics response package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/aistudios/metrics/" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Example owner metrics response require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/aistudios/metrics/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' response = http.request(request) puts response.read_body ``` ```java Example owner metrics response import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/aistudios/metrics/") .header("Content-Type", "application/json") .asString(); ``` ```php Example owner metrics response request('POST', 'https://api.example.com/api/v1/aistudios/metrics/', [ 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Example owner metrics response using RestSharp; var client = new RestClient("https://api.example.com/api/v1/aistudios/metrics/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); IRestResponse response = client.Execute(request); ``` ```swift Example owner metrics response import Foundation let headers = ["Content-Type": "application/json"] let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/aistudios/metrics/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python Request owner metrics (owner/co-creator only) import requests url = "https://api.example.com/api/v1/aistudios/metrics/" payload = { "url": "ai-research-studio" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Request owner metrics (owner/co-creator only) const url = 'https://api.example.com/api/v1/aistudios/metrics/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"url":"ai-research-studio"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Request owner metrics (owner/co-creator only) package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/aistudios/metrics/" payload := strings.NewReader("{\n \"url\": \"ai-research-studio\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Request owner metrics (owner/co-creator only) require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/aistudios/metrics/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"url\": \"ai-research-studio\"\n}" response = http.request(request) puts response.read_body ``` ```java Request owner metrics (owner/co-creator only) import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/aistudios/metrics/") .header("Content-Type", "application/json") .body("{\n \"url\": \"ai-research-studio\"\n}") .asString(); ``` ```php Request owner metrics (owner/co-creator only) request('POST', 'https://api.example.com/api/v1/aistudios/metrics/', [ 'body' => '{ "url": "ai-research-studio" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Request owner metrics (owner/co-creator only) using RestSharp; var client = new RestClient("https://api.example.com/api/v1/aistudios/metrics/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"url\": \"ai-research-studio\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Request owner metrics (owner/co-creator only) import Foundation let headers = ["Content-Type": "application/json"] let parameters = ["url": "ai-research-studio"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/aistudios/metrics/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```