Start here
Count a view
POST
/v1/community/publications/{id}/viewson https://api.auray.ai/v1Count one view of a shown work: once a day per visitor, and nobody who viewed is kept — the mark is a salted one-way digest deleted with its day.
Count one view of a shown work: once a day per visitor, and nobody who viewed is kept — the mark is a salted one-way digest deleted with its day. Takes no key; a key that holds community:write is counted by its account, and an author viewing their own work is never counted. A view that cannot be attributed answers counted: false.
#Authentication
No key needed: the public pages count their readers through the landing. A key that holds community:write is counted by its account.
#Request
#Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes |
#Example request
curl -X POST https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/viewsimport { createClient } from "@auray/client";
const auray = createClient(); // this route needs no key
const answer = await auray.platform.community.publications.view("3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d");
console.dir(answer, { depth: null });from auray_client import Client
auray = Client() # this route needs no key
answer = auray.platform.community.publications.view("3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d")
print(answer)const res = await fetch("https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views", {
method: "POST",
});
console.log(await res.json());import requests
r = requests.post(
"https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views",
)
r.raise_for_status()
print(r.json())package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("POST", "https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views", nil)
if err != nil {
panic(err)
}
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(out))
}<?php
$ch = curl_init("https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $response, PHP_EOL;require "net/http"
uri = URI("https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views")
req = Net::HTTP::Post.new(uri)
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, res.bodyimport java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views"))
.POST(HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.auray.ai/v1/community/publications/3f0c8a52-6a1d-4e8b-9c2d-7e5f4a3b2c1d/views");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");#Responses
#200 OK
OK.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
object | string | yes | — | One of "view". |
publication_id | string | yes | — | |
counted | boolean | yes | — | False when this visitor was counted already today. |
request_id | string | no | — | Mirrored in the X-Request-Id header. |
Headers:
| Header | Description |
|---|---|
RateLimit-Limit | Burst capacity. |
RateLimit-Remaining | |
RateLimit-Reset | Seconds until refill. |
X-RateLimit-Limit | |
X-RateLimit-Remaining | |
X-RateLimit-Reset | Unix seconds. The X- spelling is what client libraries read. |
X-Request-Id |
#401 Unauthorized
#403 Forbidden
#404 Not Found
#429 Too Many Requests
#503 Service Unavailable
#Status codes
| Status | Meaning |
|---|---|
200 | OK. |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
429 | Too Many Requests |
503 | Service Unavailable |
Every refusal names its code, and every code is explained at Errors.